SOMHunter Core
user-context.h
Go to the documentation of this file.
1 /* This file is part of SOMHunter.
2  *
3  * Copyright (C) 2021 Frantisek Mejzlik <frankmejzlik@protonmail.com>
4  * Mirek Kratochvil <exa.exa@gmail.com>
5  * Patrik Vesely <prtrikvesely@gmail.com>
6  *
7  * SOMHunter is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License as published by the Free
9  * Software Foundation, either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * SOMHunter is distributed in the hope that it will be useful, but WITHOUT ANY
13  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * SOMHunter. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef USER_CONTEXT_H_
22 #define USER_CONTEXT_H_
23 
24 #include <array>
25 #include <memory>
26 #include <optional>
27 #include <vector>
28 // ---
29 #include "async-som.h"
30 #include "common.h"
31 #include "dataset-features.h"
32 #include "eval-server-client.h"
33 #include "logger.h"
34 #include "search-context.h"
35 
36 namespace sh {
38 class UserContext {
39 public:
40  UserContext() = delete;
41  UserContext(const Settings& settings, const std::string& username, const DatasetFrames* p_dataset_frames,
42  const PrimaryFrameFeatures* p_dataset_features);
43 
44  const std::string& get_username() const { return _username; };
45  const DatasetFrames* get_frames() const { return _p_dataset_frames; };
47 
48  void reset() {
49  // Reset SearchContext
50  ctx.reset();
51  // Make sure we're not pushing in any old screenshot
52  ctx.screenshot_fpth = "";
53  ctx.ID = 0; //< This value means NULL state after the reset
54 
55  // Reset bookmarks
56  _bookmarks.clear();
57 
58  _history.clear();
59  //_history.emplace_back(ctx);
60 
61  _videos_seen.clear();
62  }
63 
64  // ---
65  bool operator==(const UserContext& other) const;
66 
67 public: //< This is temporary, until we support multiple users
70 
71  // *** SEARCH CONTEXT ***
73 
74  // *** USER SPECIFIC ***
75  std::string _username;
76  std::string _user_eval_server_token; //< For remote auth
77  std::vector<SearchContext> _history;
78 
81 
84 
86  std::vector<std::unique_ptr<AsyncSom>> _temp_async_SOM;
87 
91 
93 };
94 
98  const LikesCont& likes;
101 };
102 
105  size_t curr_ctx_ID;
106  const std::vector<SearchContext>& _history;
107  const std::vector<VideoFrame> targets;
108  size_t target_pos;
109 };
110 
111 }; // namespace sh
112 
113 #endif // USER_CONTEXT_H_
Definition: async-som.h:34
Definition: dataset-frames.h:162
Definition: eval-server-client.h:37
Represents CONTINOUS range of const frame pointers.
Definition: dataset-frames.h:121
Class responsible for all the logging for the given user (each user have it's own Logger....
Definition: logger.h:53
Represents exactly one state of ONE user that uses this core.
Definition: user-context.h:38
std::vector< SearchContext > _history
Definition: user-context.h:77
BookmarksCont _bookmarks
Frames selected as important.
Definition: user-context.h:89
ScreenVideosCont _videos_seen
Definition: user-context.h:92
SearchContext ctx
Definition: user-context.h:72
std::vector< std::unique_ptr< AsyncSom > > _temp_async_SOM
Definition: user-context.h:86
Logger _logger
Does all the system logs.
Definition: user-context.h:83
const DatasetFrames * get_frames() const
Definition: user-context.h:45
UserContext()=delete
AsyncSom _async_SOM
Definition: user-context.h:85
EvalServerClient _eval_server
Inteface for communicating with the evaluation server.
Definition: user-context.h:80
void reset()
Definition: user-context.h:48
bool operator==(const UserContext &other) const
Definition: user-context.cpp:56
std::string _user_eval_server_token
Definition: user-context.h:76
const PrimaryFrameFeatures * get_features() const
Definition: user-context.h:46
bool _force_result_log
Definition: user-context.h:90
const std::string & get_username() const
Definition: user-context.h:44
std::string _username
Definition: user-context.h:75
const PrimaryFrameFeatures * _p_dataset_features
Definition: user-context.h:69
const DatasetFrames * _p_dataset_frames
Definition: user-context.h:68
Definition: common-types.h:33
std::set< VideoId > ScreenVideosCont
Definition: common-types.h:90
std::set< FrameId > LikesCont
Definition: common-types.h:86
std::set< FrameId > BookmarksCont
Definition: common-types.h:87
Result type get_display returns.
Definition: user-context.h:96
FramePointerRange _dataset_frames
Definition: user-context.h:97
const LikesCont & _bookmarks
Definition: user-context.h:99
const LikesCont & likes
Definition: user-context.h:98
const ScreenVideosCont & _videos_seen
Definition: user-context.h:100
Result type rescore returns.
Definition: user-context.h:104
size_t target_pos
Definition: user-context.h:108
const std::vector< VideoFrame > targets
Definition: user-context.h:107
size_t curr_ctx_ID
Definition: user-context.h:105
const std::vector< SearchContext > & _history
Definition: user-context.h:106
Represents exactly one momentary state of a search session.
Definition: search-context.h:44
void reset()
Definition: search-context.h:52
std::size_t ID
Definition: search-context.h:60
std::string screenshot_fpth
Definition: search-context.h:85
Parsed current config of the core.
Definition: settings.h:190