OpenRTM-aist 2.0.2
Loading...
Searching...
No Matches
ConfigurationListener.h
Go to the documentation of this file.
1// -*- C++ -*-
19#ifndef RTC_CONFIGURATIONLISTENER_H
20#define RTC_CONFIGURATIONLISTENER_H
21
22#include <coil/Properties.h>
23#include <mutex>
24
25#include <utility>
26#include <vector>
27#include <array>
28
29namespace RTC
30{
31 //============================================================
50
51
75 {
76 public:
101 {
103 {
104 static const char* const typeString[] =
105 {
106 "ON_UPDATE_CONFIG_PARAM",
107 "CONFIG_PARAM_LISTENER_NUM"
108 };
109 return typeString[static_cast<uint8_t>(type)];
110 }
111 return "";
112 }
113
122
138 virtual void operator()(const char* config_set_name,
139 const char* config_param_name) = 0;
140 };
141
142
143 //============================================================
166
191 {
192 public:
217 static const char* toString(ConfigurationSetListenerType type)
218 {
220 {
221 static const char* const typeString[] =
222 {
223 "ON_SET_CONFIG_SET",
224 "ON_ADD_CONFIG_SET",
225 "CONFIG_SET_LISTENER_NUM"
226 };
227 return typeString[static_cast<uint8_t>(type)];
228 }
229 return "";
230 }
231
240
256 virtual void operator()(const coil::Properties& config_set) = 0;
257 };
258
259
260 //============================================================
278
304 {
305 public:
331 {
333 {
334 static const char* const typeString[] =
335 {
336 "ON_UPDATE_CONFIG_SET",
337 "ON_REMOVE_CONFIG_SET",
338 "ON_ACTIVATE_CONFIG_SET",
339 "CONFIG_SET_NAME_LISTENER_NUM"
340 };
341 return typeString[static_cast<uint8_t>(type)];
342 }
343 return "";
344 }
345
354
370 virtual void operator()(const char* config_set_name) = 0;
371 };
372
373
391 {
392 using Entry = std::pair<ConfigurationParamListener*, bool>;
393 public:
410
432 void addListener(ConfigurationParamListener* listener, bool autoclean);
433
452
472 void notify(const char* config_set_name, const char* config_param_name);
473
474 private:
475 std::vector<Entry> m_listeners;
476 std::mutex m_mutex;
477 };
478
479
480 //============================================================
498 {
499 using Entry = std::pair<ConfigurationSetListener*, bool>;
500 public:
517
539 void addListener(ConfigurationSetListener* listener, bool autoclean);
540
559
579 void notify(const coil::Properties& config_set);
580
581 private:
582 std::vector<Entry> m_listeners;
583 std::mutex m_mutex;
584 };
585
586
587 //============================================================
605 {
606 using Entry = std::pair<ConfigurationSetNameListener*, bool>;
607 public:
616
625
647 void addListener(ConfigurationSetNameListener* listener, bool autoclean);
648
667
685 void notify(const char* config_set_name);
686
687 private:
688 std::vector<Entry> m_listeners;
689 std::mutex m_mutex;
690 };
691
692 //------------------------------------------------------------
707 {
708 public:
791 bool addListener(ConfigurationSetListenerType type, ConfigurationSetListener* listener, bool autoclean=true);
884 inline bool notify(ConfigurationParamListenerType type, const char* config_set_name, const char* config_param_name)
885 {
886 if (static_cast<uint8_t>(type) < configparam_.size())
887 {
888 configparam_[static_cast<uint8_t>(type)].notify(config_set_name, config_param_name);
889 return true;
890 }
891 return false;
892 }
913 inline bool notify(ConfigurationSetListenerType type, const coil::Properties& config_set)
914 {
915 if (static_cast<uint8_t>(type) < configset_.size())
916 {
917 configset_[static_cast<uint8_t>(type)].notify(config_set);
918 return true;
919 }
920 return false;
921 }
942 inline bool notify(ConfigurationSetNameListenerType type, const char* config_set_name)
943 {
944 if (static_cast<uint8_t>(type) < configsetname_.size())
945 {
946 configsetname_[static_cast<uint8_t>(type)].notify(config_set_name);
947 return true;
948 }
949 return false;
950 }
951 private:
961 std::array<ConfigurationParamListenerHolder, static_cast<uint8_t>(ConfigurationParamListenerType::CONFIG_PARAM_LISTENER_NUM)> configparam_;
971 std::array<ConfigurationSetListenerHolder, static_cast<uint8_t>(ConfigurationSetListenerType::CONFIG_SET_LISTENER_NUM)> configset_;
981 std::array<ConfigurationSetNameListenerHolder, static_cast<uint8_t>(ConfigurationSetNameListenerType::CONFIG_SET_NAME_LISTENER_NUM)> configsetname_;
982 };
983
984
985} // namespace RTC
986
987#endif // RTC_CONFIGURATIONLISTENER_H
Definition ConfigurationListener.h:707
bool removeListener(ConfigurationSetNameListenerType type, ConfigurationSetNameListener *listener)
Remove the listener.
bool notify(ConfigurationParamListenerType type, const char *config_set_name, const char *config_param_name)
Definition ConfigurationListener.h:884
bool removeListener(ConfigurationParamListenerType type, ConfigurationParamListener *listener)
Remove the listener.
bool notify(ConfigurationSetNameListenerType type, const char *config_set_name)
Definition ConfigurationListener.h:942
bool addListener(ConfigurationParamListenerType type, ConfigurationParamListener *listener, bool autoclean=true)
Add the listener.
bool addListener(ConfigurationSetListenerType type, ConfigurationSetListener *listener, bool autoclean=true)
Add the listener.
bool notify(ConfigurationSetListenerType type, const coil::Properties &config_set)
Definition ConfigurationListener.h:913
~ConfigurationListeners()
Destructor .
bool addListener(ConfigurationSetNameListenerType type, ConfigurationSetNameListener *listener, bool autoclean=true)
Add the listener.
bool removeListener(ConfigurationSetListenerType type, ConfigurationSetListener *listener)
Remove the listener.
ConfigurationParamListener holder class.
Definition ConfigurationListener.h:391
void notify(const char *config_set_name, const char *config_param_name)
Notify listeners.
void removeListener(ConfigurationParamListener *listener)
Remove the listener.
virtual ~ConfigurationParamListenerHolder()
Destructor .
void addListener(ConfigurationParamListener *listener, bool autoclean)
Add the listener.
ConfigurationParamListener class.
Definition ConfigurationListener.h:75
virtual void operator()(const char *config_set_name, const char *config_param_name)=0
Virtual Callback function.
static const char * toString(ConfigurationParamListenerType type)
Convert ConfigurationParamListenerType into the string.
Definition ConfigurationListener.h:100
virtual ~ConfigurationParamListener()
Destructor .
ConfigurationSetListener holder class.
Definition ConfigurationListener.h:498
void notify(const coil::Properties &config_set)
Notify listeners.
void removeListener(ConfigurationSetListener *listener)
Remove the listener.
void addListener(ConfigurationSetListener *listener, bool autoclean)
Add the listener.
ConfigurationSetListenerHolder()
Constructor .
virtual ~ConfigurationSetListenerHolder()
Destructor .
ConfigurationSetListener class.
Definition ConfigurationListener.h:191
virtual ~ConfigurationSetListener()
Destructor .
static const char * toString(ConfigurationSetListenerType type)
Convert ConfigurationSetNameListenerType into the string.
Definition ConfigurationListener.h:217
virtual void operator()(const coil::Properties &config_set)=0
Virtual Callback function.
ConfigurationSetNameListener holder class.
Definition ConfigurationListener.h:605
void addListener(ConfigurationSetNameListener *listener, bool autoclean)
Add the listener.
void removeListener(ConfigurationSetNameListener *listener)
Remove the listener.
virtual ~ConfigurationSetNameListenerHolder()
Destructor .
void notify(const char *config_set_name)
Notify listeners.
ConfigurationSetNameListener class.
Definition ConfigurationListener.h:304
static const char * toString(ConfigurationSetNameListenerType type)
Convert ConfigurationSetNameListenerType into the string.
Definition ConfigurationListener.h:330
virtual void operator()(const char *config_set_name)=0
Virtual Callback function.
virtual ~ConfigurationSetNameListener()
Destructor .
RT-Component.
ConfigurationSetNameListenerType
The types of ConfigurationSetNameListener.
Definition ConfigurationListener.h:272
ConfigurationSetListenerType
The types of ConfigurationSetListener.
Definition ConfigurationListener.h:161
ConfigurationParamListenerType
The types of ConnectorDataListener.
Definition ConfigurationListener.h:46