RTC Toolkit  2.0.0
rtcObjectConfig.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_RTCSUPERVISOR_RTCOBJECTCONFIG_HPP
13 #define RTCTK_RTCSUPERVISOR_RTCOBJECTCONFIG_HPP
14 
20 
21 namespace rtctk::rtcSupervisor {
22 
24 public:
25  std::string m_name;
26  std::string m_rr_uri;
27  std::string m_ps_uri;
28 
29  RtcObjectDescription(const std::string &name,
30  const std::string &rr_uri,
31  const std::string &ps_uri) {
32  m_name = name;
33  m_rr_uri = rr_uri;
34  m_ps_uri = ps_uri;
35  }
36 
38  m_name = "";
39  m_rr_uri = "";
40  m_ps_uri = "";
41  }
42 };
43 
45 public:
47 
48  std::list<RtcObjectDescription> objects;
49 
52 };
53 
55 public:
56  RtcObjectConfig(std::string name,
60 
61  virtual ~RtcObjectConfig();
62 
63  // @brief Read config from RR and build lists
64  void BuildFromRuntimeRepo();
65 
66  // @brief Find object or NULL
67  std::shared_ptr<RtcObject> FindObject(const std::string &name);
68 
69  // @brief Return the all object list
70  std::shared_ptr<RtcCommandRequestList> AllObjectsRequestList() {
71  return m_objects_request_list;
72  };
73 
74  // @brief Update state information from event, evaluate the new global state
75  void OnStateEventReceived(const double timestamp,
76  const std::string &name,
77  const std::string &state,
78  std::string &gstate,
79  std::string &gsubstate,
80  bool &gerror,
81  std::string &gerror_who);
82 
83  // @brief Give access to the object list
84  std::list<std::shared_ptr<RtcObject>> &ObjectList() {
85  return m_objects_list;
86  };
87 
88  // @brief Give access to the pub sub list
89  std::vector<elt::mal::Uri> &PubSubURIs() {
90  return m_pub_sub_uris;
91  };
92 
93  // @brief Evaluate global state by traversing all objects
94  void EvaluateBelievedState(std::string &gstate,
95  std::string &gsubstate,
96  bool &gerror,
97  std::string &gerror_who);
98 
99  // @brief Free memory (if needed)
100  void Cleanup();
101 
102  // @brief Dump for debugging
103  void Dump();
104 
105 private:
106  // @brief name of the component (needed for OLDB access at least)
107  std::string m_name;
108 
109  // @brief lists of objects and commands
110  std::list<std::shared_ptr<RtcObject>> m_objects_list;
111  std::shared_ptr<RtcCommandRequestList> m_objects_request_list;
112 
113  // @brief the configuration as loaded from the runtime repo
114  // names and URIs
115  RtcObjectsDescription m_objects_description;
116 
117  void BuildObjectsList();
118  void BuildObjectsRequestList();
119 
120  // @brief ref to rtr and svc
124 
125  std::vector<elt::mal::Uri> m_pub_sub_uris;
126 };
127 
128 } // namespace rtctk::rtcSupervisor
129 
130 #endif // RTCTK_RTCSUPERVISOR_RTCOBJECTCONFIG_HPP
rtctk::rtcSupervisor
Definition: rtcCommandRequest.hpp:19
wscript.name
name
Definition: wscript:15
rtctk::rtcSupervisor::RtcObjectConfig::FindObject
std::shared_ptr< RtcObject > FindObject(const std::string &name)
Definition: rtcObjectConfig.cpp:91
rtcCommandRequestList.hpp
Handles a list of command requests to be run sequentially or in parallel.
rtctk::rtcSupervisor::RtcObjectConfig::Cleanup
void Cleanup()
serviceDiscovery.hpp
Class that implements a very basic service discover mechanism.
rtctk::rtcSupervisor::RtcObjectConfig::ObjectList
std::list< std::shared_ptr< RtcObject > > & ObjectList()
Definition: rtcObjectConfig.hpp:84
rtctk::rtcSupervisor::RtcObjectDescription
Definition: rtcObjectConfig.hpp:23
rtctk::rtcSupervisor::RtcObjectConfig::BuildFromRuntimeRepo
void BuildFromRuntimeRepo()
Definition: rtcObjectConfig.cpp:78
rtctk::componentFramework::ServiceDiscovery
Class that implements a very basic service discovery mechanism.
Definition: serviceDiscovery.hpp:29
rtctk::rtcSupervisor::RtcObjectDescription::m_rr_uri
std::string m_rr_uri
Definition: rtcObjectConfig.hpp:26
rtctk::rtcSupervisor::RtcObjectsDescription::RtcObjectsDescription
RtcObjectsDescription()
Definition: rtcObjectConfig.cpp:203
rtctk::rtcSupervisor::RtcObjectsDescription::objects
std::list< RtcObjectDescription > objects
Definition: rtcObjectConfig.hpp:48
rtctk::rtcSupervisor::RtcObjectConfig::OnStateEventReceived
void OnStateEventReceived(const double timestamp, const std::string &name, const std::string &state, std::string &gstate, std::string &gsubstate, bool &gerror, std::string &gerror_who)
Called from the rtcServer business logic when a state change event is recrived from any of the superv...
Definition: rtcObjectConfig.cpp:111
rtctk::rtcSupervisor::RtcObjectConfig
Definition: rtcObjectConfig.hpp:54
rtctk::rtcSupervisor::RtcObjectConfig::Dump
void Dump()
rtctk::rtcSupervisor::RtcObjectConfig::AllObjectsRequestList
std::shared_ptr< RtcCommandRequestList > AllObjectsRequestList()
Definition: rtcObjectConfig.hpp:70
rtctk::rtcSupervisor::RtcObjectDescription::RtcObjectDescription
RtcObjectDescription(const std::string &name, const std::string &rr_uri, const std::string &ps_uri)
Definition: rtcObjectConfig.hpp:29
rtctk::rtcSupervisor::RtcObjectConfig::~RtcObjectConfig
virtual ~RtcObjectConfig()
Definition: rtcObjectConfig.cpp:38
rtctk_ctrl_mon_tool.state
def state(ctx, str component)
Definition: rtctk_ctrl_mon_tool.py:158
rtctk::componentFramework::OldbIf
Definition: oldbIf.hpp:20
rtctk::rtcSupervisor::RtcObjectsDescription::LoadFromRuntimeRepo
void LoadFromRuntimeRepo(rtctk::componentFramework::RuntimeRepoIf &rtr, rtctk::componentFramework::ServiceDiscovery &svc)
Build the list of object descriptions based on the depl.objectlist.
Definition: rtcObjectConfig.cpp:213
rtctk::componentFramework::RuntimeRepoIf
Definition: runtimeRepoIf.hpp:20
rtctk::rtcSupervisor::RtcObjectConfig::EvaluateBelievedState
void EvaluateBelievedState(std::string &gstate, std::string &gsubstate, bool &gerror, std::string &gerror_who)
Evaluate the believed state by traversing the list of objects and finding the minimum state/substate.
Definition: rtcObjectConfig.cpp:139
rtctk::rtcSupervisor::RtcObjectDescription::RtcObjectDescription
RtcObjectDescription()
Definition: rtcObjectConfig.hpp:37
rtctk::rtcSupervisor::RtcObjectDescription::m_name
std::string m_name
Definition: rtcObjectConfig.hpp:25
runtimeRepoIf.hpp
Header file for RuntimeRepoIf, which defines the API for RuntimeRepoAdapters.
rtctk::rtcSupervisor::RtcObjectConfig::RtcObjectConfig
RtcObjectConfig(std::string name, rtctk::componentFramework::RuntimeRepoIf &rtr, rtctk::componentFramework::ServiceDiscovery &svc, rtctk::componentFramework::OldbIf &oldb)
Definition: rtcObjectConfig.cpp:24
rtctk::rtcSupervisor::RtcObjectDescription::m_ps_uri
std::string m_ps_uri
Definition: rtcObjectConfig.hpp:27
rtcSupervisorLib.hpp
Standard enums for rtcSupervisor.
rtctk::rtcSupervisor::RtcObjectsDescription
Definition: rtcObjectConfig.hpp:44
rtctk::rtcSupervisor::RtcObjectConfig::PubSubURIs
std::vector< elt::mal::Uri > & PubSubURIs()
Definition: rtcObjectConfig.hpp:89
oldbIf.hpp
Header file for OldbIf, which defines the API for OldbAdapters.