00001
00019 #ifndef RTC_CONFIGURATIONLISTENER_H
00020 #define RTC_CONFIGURATIONLISTENER_H
00021
00022 #include <vector>
00023 #include <coil/Properties.h>
00024
00025 namespace RTC
00026 {
00027
00041 enum ConfigurationParamListenerType
00042 {
00043 ON_UPDATE_CONFIG_PARAM,
00044 CONFIG_PARAM_LISTENER_NUM
00045 };
00046
00047
00070 class ConfigurationParamListener
00071 {
00072 public:
00096 static const char* toString(ConfigurationParamListenerType type)
00097 {
00098 static const char* typeString[] =
00099 {
00100 "ON_UPDATE_CONFIG_PARAM",
00101 "CONFIG_PARAM_LISTENER_NUM"
00102 };
00103 if (type < CONFIG_PARAM_LISTENER_NUM)
00104 {
00105 return typeString[type];
00106 }
00107 return "";
00108 }
00109
00117 virtual ~ConfigurationParamListener();
00118
00134 virtual void operator()(const char* config_set_name,
00135 const char* config_param_name) = 0;
00136 };
00137
00138
00139
00156 enum ConfigurationSetListenerType
00157 {
00158 ON_SET_CONFIG_SET,
00159 ON_ADD_CONFIG_SET,
00160 CONFIG_SET_LISTENER_NUM
00161 };
00162
00186 class ConfigurationSetListener
00187 {
00188 public:
00213 static const char* toString(ConfigurationSetListenerType type)
00214 {
00215 static const char* typeString[] =
00216 {
00217 "ON_SET_CONFIG_SET",
00218 "ON_ADD_CONFIG_SET",
00219 "CONFIG_SET_LISTENER_NUM"
00220 };
00221 if (type < CONFIG_SET_LISTENER_NUM) { return typeString[type]; }
00222 return "";
00223 }
00224
00232 virtual ~ConfigurationSetListener();
00233
00249 virtual void operator()(const coil::Properties& config_set) = 0;
00250 };
00251
00252
00253
00264 enum ConfigurationSetNameListenerType
00265 {
00266 ON_UPDATE_CONFIG_SET,
00267 ON_REMOVE_CONFIG_SET,
00268 ON_ACTIVATE_CONFIG_SET,
00269 CONFIG_SET_NAME_LISTENER_NUM
00270 };
00271
00296 class ConfigurationSetNameListener
00297 {
00298 public:
00323 static const char* toString(ConfigurationSetNameListenerType type)
00324 {
00325 static const char* typeString[] =
00326 {
00327 "ON_UPDATE_CONFIG_SET",
00328 "ON_REMOVE_CONFIG_SET",
00329 "ON_ACTIVATE_CONFIG_SET",
00330 "CONFIG_SET_NAME_LISTENER_NUM"
00331 };
00332 if (type < CONFIG_SET_NAME_LISTENER_NUM) { return typeString[type]; }
00333 return "";
00334 }
00335
00343 virtual ~ConfigurationSetNameListener();
00344
00360 virtual void operator()(const char* config_set_name) = 0;
00361 };
00362
00363
00380 class ConfigurationParamListenerHolder
00381 {
00382 typedef std::pair<ConfigurationParamListener*, bool> Entry;
00383 public:
00391 ConfigurationParamListenerHolder();
00399 virtual ~ConfigurationParamListenerHolder();
00400
00422 void addListener(ConfigurationParamListener* listener, bool autoclean);
00423
00441 void removeListener(ConfigurationParamListener* listener);
00442
00462 void notify(const char* config_set_name, const char* config_param_name);
00463
00464 private:
00465 std::vector<Entry> m_listeners;
00466 };
00467
00468
00469
00486 class ConfigurationSetListenerHolder
00487 {
00488 typedef std::pair<ConfigurationSetListener*, bool> Entry;
00489 public:
00497 ConfigurationSetListenerHolder();
00505 virtual ~ConfigurationSetListenerHolder();
00506
00528 void addListener(ConfigurationSetListener* listener, bool autoclean);
00529
00547 void removeListener(ConfigurationSetListener* listener);
00548
00568 void notify(const coil::Properties& config_set);
00569
00570 private:
00571 std::vector<Entry> m_listeners;
00572 };
00573
00574
00575
00592 class ConfigurationSetNameListenerHolder
00593 {
00594 typedef std::pair<ConfigurationSetNameListener*, bool> Entry;
00595 public:
00603 ConfigurationSetNameListenerHolder();
00604
00612 virtual ~ConfigurationSetNameListenerHolder();
00613
00635 void addListener(ConfigurationSetNameListener* listener, bool autoclean);
00636
00654 void removeListener(ConfigurationSetNameListener* listener);
00655
00673 void notify(const char* config_set_name);
00674
00675 private:
00676 std::vector<Entry> m_listeners;
00677 };
00678
00679
00693 class ConfigurationListeners
00694 {
00695 public:
00705 ConfigurationParamListenerHolder
00706 configparam_[CONFIG_PARAM_LISTENER_NUM];
00716 ConfigurationSetListenerHolder
00717 configset_[CONFIG_SET_LISTENER_NUM];
00727 ConfigurationSetNameListenerHolder
00728 configsetname_[CONFIG_SET_NAME_LISTENER_NUM];
00729 };
00730
00731
00732 };
00733
00734 #endif // RTC_CONFIGURATIONLISTENER_H