forb
remote_registry.hpp
1 //
2 // Created by gabriele on 04/11/18.
3 //
4 
5 #ifndef LIBFORB_REMOTE_REGISTRY_HPP
6 #define LIBFORB_REMOTE_REGISTRY_HPP
7 
8 #include <map>
9 
10 #include <forb/base_stub.hpp>
11 
12 namespace forb {
13 
18  /* ********************************************** CUSTOM TYPES ********************************************** */
19  private:
20  // Forward declaration, see implementation file.
21  struct remote_obj_entry;
22 
23  /* ************************************************ ALIASES ************************************************* */
24 
26  using obj_map_t = std::map<std::string, remote_obj_entry>;
27 
28  /* *********************************************** ATTRIBUTES *********************************************** */
29 
31  obj_map_t remote_objects;
32 
33  /* ********************************************** CONSTRUCTORS ********************************************** */
34  public:
36  explicit remote_registry(std::string conf_file_name);
37 
38  /**************************************************************************************************************/
39  public:
41  ~remote_registry() noexcept;
42 
44  remote_registry(const remote_registry &other);
45 
48 
50  remote_registry(remote_registry &&other) noexcept;
51 
53  remote_registry &operator=(remote_registry &&other) noexcept;
54 
55  /**************************************************************************************************************/
56  public:
58  remote_var get(const std::string &obj_name) const {
59  return get(obj_name, false, 0);
60  };
61 
65  remote_var get(const std::string &obj_name, base_stub::buffer_size_t buffer_size) {
66  return get(obj_name, false, buffer_size);
67  };
68 
72  remote_var get_force_socket(const std::string &obj_name) const {
73  return get(obj_name, true, 0);
74  };
75 
76  private:
80  remote_var get(const std::string &obj_name, bool force_socket, base_stub::buffer_size_t buffer_size) const;
81  };
82 
83 } // namespace forb
84 
85 
86 #endif //LIBFORB_REMOTE_REGISTRY_HPP
~remote_registry() noexcept
Destructor.
This function implements a memcpy abstract that is valid also for volatile data.
Definition: base_skeleton.hpp:15
Emulates a complete registry of all active remote objects that use this framework.
Definition: remote_registry.hpp:17
remote_var get_force_socket(const std::string &obj_name) const
Returns a reference to the object identified by the obj_name argument, a NIL pointer otherwise...
Definition: remote_registry.hpp:72
The type that will store all information about a remote object that will be parsed from the JSON file...
Definition: remote_registry.cpp:17
remote_registry & operator=(const remote_registry &other)
This class does supports copy assignment.
remote_registry(std::string conf_file_name)
Constructs a new registry.
Definition: remote_registry.cpp:48
forb::streams::shared_memory::size_t buffer_size_t
The type of the buffer size.
Definition: base_stub.hpp:43
std::unique_ptr< base_stub > remote_var
Unique pointer to a base_class object (or a derived class).
Definition: base_stub.hpp:30