24 #include <config/netconf.h> 25 #include <config/net_messages.h> 26 #include <config/memory.h> 27 #include <config/net_list_content.h> 29 #include <core/threading/mutex.h> 30 #include <core/threading/interruptible_barrier.h> 31 #include <netcomm/fawkes/client.h> 32 #include <netcomm/fawkes/message.h> 33 #include <netcomm/utils/exceptions.h> 35 #include <logging/liblogger.h> 36 #include <utils/misc/string_conversions.h> 54 :
Exception(
"Could not enable mirroring: %s", msg)
79 unsigned int mirror_timeout_sec)
81 __mirror_timeout_sec = mirror_timeout_sec;
84 __mirror_mode =
false;
85 __mirror_mode_before_connection_dead =
false;
86 __mirror_init_waiting =
false;
94 e.
append(
"Failed to register for config manager component on network client");
103 set_mirror_mode(
false);
104 c->deregister_handler(FAWKES_CID_CONFIGMANAGER);
108 delete __mirror_init_barrier;
131 while ( i->
next() ) {
134 }
else if ( i->
is_int() ) {
142 set_string(i->
path(), s);
153 bool rv = i->
valid();
178 if ( __mirror_mode ) {
179 s = mirror_config->get_type(path);
194 return (get_type(path) ==
"float");
201 return (get_type(path) ==
"unsigned int");
208 return (get_type(path) ==
"int");
215 return (get_type(path) ==
"bool");
222 return (get_type(path) ==
"string");
232 NetworkConfiguration::send_get(
const char *path,
unsigned int msgid,
unsigned int expected_reply)
234 if ( ! __connected ) {
236 "client connection is not alive");
239 strncpy(g->
cp.
path, path, CONFIG_MSG_PATH_LENGTH);
243 c->enqueue_and_wait(omsg);
250 if ( msg->msgid() != expected_reply ) {
251 unsigned int msg_msgid = msg->msgid();
255 throw Exception(
"NetworkConfiguration::send_get: expected %u, but got %u",
256 expected_reply, msg_msgid);
264 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
266 "Maximum length for path exceeded");
268 if ( ! __connected ) {
270 "client connection is not alive");
276 if ( __mirror_mode ) {
278 f = mirror_config->get_float(path);
280 e.
append(
"NetworkConfiguration[mirroring]::get_float: exception in mirror database");
286 send_get(path, MSG_CONFIG_GET_FLOAT, MSG_CONFIG_FLOAT_VALUE);
292 throw Exception(
"NetworkConfiguration: received list of and not a single value");
300 e.
append(
"NetworkConfiguration::get_float: Fetching float failed");
319 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
321 "Maximum length for path exceeded");
323 if ( ! __connected ) {
325 "client connection is not alive");
331 if ( __mirror_mode ) {
333 u = mirror_config->get_uint(path);
335 e.
append(
"NetworkConfiguration[mirroring]::get_uint: exception in mirror database");
341 send_get(path, MSG_CONFIG_GET_UINT, MSG_CONFIG_UINT_VALUE);
347 throw Exception(
"NetworkConfiguration: received list of and not a single value");
355 e.
append(
"NetworkConfiguration::get_uint: Fetching unsigned int failed");
374 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
376 "Maximum length for path exceeded");
378 if ( ! __connected ) {
380 "client connection is not alive");
386 if ( __mirror_mode ) {
388 i = mirror_config->get_int(path);
390 e.
append(
"NetworkConfiguration[mirroring]::get_int: exception in mirror database");
396 send_get(path, MSG_CONFIG_GET_INT, MSG_CONFIG_INT_VALUE);
402 throw Exception(
"NetworkConfiguration: received list of and not a single value");
410 e.
append(
"NetworkConfiguration::get_int: Fetching int failed");
429 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
431 "Maximum length for path exceeded");
433 if ( ! __connected ) {
435 "client connection is not alive");
441 if ( __mirror_mode ) {
443 b = mirror_config->get_bool(path);
445 e.
append(
"NetworkConfiguration[mirroring]::get_bool: exception in mirror database");
451 send_get(path, MSG_CONFIG_GET_BOOL, MSG_CONFIG_BOOL_VALUE);
457 throw Exception(
"NetworkConfiguration: received list of and not a single value");
465 e.
append(
"NetworkConfiguration::get_bool: Fetching bool failed");
484 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
486 "Maximum length for path exceeded");
488 if ( ! __connected ) {
490 "client connection is not alive");
496 if ( __mirror_mode ) {
498 s = mirror_config->get_string(path);
500 e.
append(
"NetworkConfiguration[mirroring]::get_string: exception in mirror database");
506 send_get(path, MSG_CONFIG_GET_STRING, MSG_CONFIG_STRING_VALUE);
512 throw Exception(
"NetworkConfiguration: received list of and not a single value");
522 e.
append(
"NetworkConfiguration::get_string: Fetching string failed");
543 std::vector<unsigned int>
561 std::vector<std::string>
571 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
573 "Maximum length for path exceeded");
575 if ( ! __connected ) {
577 "client connection is not alive");
583 if ( __mirror_mode ) {
585 s = mirror_config->get_comment(path);
587 e.
append(
"NetworkConfiguration[mirroring]::get_comment: exception in mirror database");
593 send_get(path, MSG_CONFIG_GET_COMMENT, MSG_CONFIG_COMMENT_VALUE);
602 e.
append(
"NetworkConfiguration::get_comment: Fetching int failed");
621 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
623 "Maximum length for path exceeded");
625 if ( ! __connected ) {
627 "client connection is not alive");
633 if ( __mirror_mode ) {
635 s = mirror_config->get_default_comment(path);
637 e.
append(
"NetworkConfiguration[mirroring]::get_default_comment: " 638 "exception in mirror database");
644 send_get(path, MSG_CONFIG_GET_DEFAULT_COMMENT, MSG_CONFIG_COMMENT_VALUE);
653 e.
append(
"NetworkConfiguration::get_comment: Fetching int failed");
672 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
674 "Maximum length for path exceeded");
676 if ( ! __connected ) {
678 "client connection is not alive");
684 if ( __mirror_mode ) {
686 i = mirror_config->get_value(path);
688 e.
append(
"NetworkConfiguration[mirroring]::get_float: exception in mirror database");
694 strncpy(g->
cp.
path, path, CONFIG_MSG_PATH_LENGTH);
696 MSG_CONFIG_GET_VALUE,
698 c->enqueue_and_wait(omsg);
718 NetworkConfiguration::set_value_internal(
unsigned int msg_type,
719 const char *path, uint16_t num_values,
720 size_t data_size,
void *data)
722 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
724 "Maximum length for path exceeded");
726 if ( ! __connected ) {
728 "client connection is not alive");
736 strncpy(cd->
path, path, CONFIG_MSG_PATH_LENGTH);
740 memcpy(mdata, data, data_size);
742 c->enqueue_and_wait(omsg);
743 if ( ! __mirror_mode && (msg != NULL) ) {
753 set_value_internal(MSG_CONFIG_SET_FLOAT, path, 0,
sizeof(
float), &f);
760 set_value_internal(MSG_CONFIG_SET_DEFAULT_FLOAT, path, 0,
sizeof(
float), &f);
767 set_value_internal(MSG_CONFIG_SET_UINT, path, 0,
sizeof(uint32_t), &uint);
774 set_value_internal(MSG_CONFIG_SET_DEFAULT_UINT, path, 0,
sizeof(uint32_t), &uint);
781 set_value_internal(MSG_CONFIG_SET_INT, path, 0,
sizeof(int32_t), &i);
788 set_value_internal(MSG_CONFIG_SET_DEFAULT_INT, path, 0,
sizeof(int32_t), &i);
795 int32_t bs[1] = { b ? 1 : 0 };
796 set_value_internal(MSG_CONFIG_SET_BOOL, path, 0,
sizeof(int32_t), bs);
803 int32_t bs[1] = { b ? 1 : 0 };
804 set_value_internal(MSG_CONFIG_SET_DEFAULT_BOOL, path, 0,
sizeof(int32_t), bs);
811 size_t s_length = strlen(s);
813 void *data = malloc(data_size);
817 set_value_internal(MSG_CONFIG_SET_STRING, path, 0, data_size, data);
825 size_t s_length = strlen(s);
827 void *data = malloc(data_size);
831 set_value_internal(MSG_CONFIG_SET_DEFAULT_STRING, path, 0, data_size, data);
839 set_string(path, s.c_str());
846 set_default_string(path, s.c_str());
913 NetworkConfiguration::erase_internal(
const char *path,
bool is_default)
915 if ( strlen(path) > CONFIG_MSG_PATH_LENGTH ) {
917 "Maximum length for path exceeded");
919 if ( ! __connected ) {
921 "client connection is not alive");
926 MSG_CONFIG_ERASE_VALUE,
930 strncpy(m->
cp.
path, path, CONFIG_MSG_PATH_LENGTH);
931 c->enqueue_and_wait(omsg);
932 if ( ! __mirror_mode && (msg != NULL) ) {
943 erase_internal(path,
false);
950 erase_internal(path,
true);
966 unsigned int id)
throw()
968 if ( m->cid() == FAWKES_CID_CONFIGMANAGER ) {
970 if ( __mirror_mode ) {
971 switch (m->msgid()) {
972 case MSG_CONFIG_LIST:
980 switch ( cle->
type ) {
981 case MSG_CONFIG_FLOAT_VALUE:
987 for (
volatile unsigned int j = 0; j < cle->
cp.
num_values; ++j) {
988 values[j] = msg_values[j];
990 mirror_config->set_floats(cle->
cp.
path, values);
993 mirror_config->set_default_float(cle->
cp.
path, *msg_values);
995 mirror_config->set_float(cle->
cp.
path, *msg_values);
1001 case MSG_CONFIG_INT_VALUE:
1003 int32_t *msg_values =
1007 for (
volatile unsigned int j = 0; j < cle->
cp.
num_values; ++j) {
1008 values[j] = msg_values[j];
1010 mirror_config->set_ints(cle->
cp.
path, values);
1013 mirror_config->set_default_int(cle->
cp.
path, *msg_values);
1015 mirror_config->set_int(cle->
cp.
path, *msg_values);
1021 case MSG_CONFIG_UINT_VALUE:
1023 uint32_t *msg_values =
1027 for (
volatile unsigned int j = 0; j < cle->
cp.
num_values; ++j) {
1028 values[j] = msg_values[j];
1030 mirror_config->set_uints(cle->
cp.
path, values);
1033 mirror_config->set_default_uint(cle->
cp.
path, *msg_values);
1035 mirror_config->set_uint(cle->
cp.
path, *msg_values);
1041 case MSG_CONFIG_BOOL_VALUE:
1043 int32_t *msg_values =
1047 for (
volatile unsigned int j = 0; j < cle->
cp.
num_values; ++j) {
1048 values[j] = (msg_values[j] != 0);
1050 mirror_config->set_bools(cle->
cp.
path, values);
1053 mirror_config->set_default_bool(cle->
cp.
path, (*msg_values != 0));
1055 mirror_config->set_bool(cle->
cp.
path, (*msg_values != 0));
1061 case MSG_CONFIG_STRING_VALUE:
1065 std::vector<std::string> values(cle->
cp.
num_values,
"");
1066 for (
volatile unsigned int j = 0; j < cle->
cp.
num_values; ++j) {
1069 values[j] = std::string(msg_string, csv->
s_length);
1072 mirror_config->set_strings(cle->
cp.
path, values);
1077 mirror_config->set_default_string(cle->
cp.
path,
1078 std::string(msg_string, csv->
s_length).c_str());
1080 mirror_config->set_string(cle->
cp.
path,
1081 std::string(msg_string, csv->
s_length).c_str());
1087 case MSG_CONFIG_COMMENT_VALUE:
1097 for (ChangeHandlerMultimap::const_iterator j = _change_handlers.begin(); j != _change_handlers.end(); ++j) {
1098 _ch_range = _change_handlers.equal_range((*j).first);
1099 for (ChangeHandlerMultimap::const_iterator i = _ch_range.first; i != _ch_range.second; ++i) {
1100 mirror_config->add_change_handler((*i).second);
1104 if (__mirror_init_waiting) {
1105 __mirror_init_barrier->wait();
1109 case MSG_CONFIG_VALUE_ERASED:
1113 mirror_config->erase_default(em->
cp.
path);
1115 mirror_config->erase(em->
cp.
path);
1119 LibLogger::log_warn(
"NetworkConfiguration",
"[mirroring]::inboundReceived: erasing failed");
1123 case MSG_CONFIG_FLOAT_VALUE:
1128 std::vector<float> floats(cd->
num_values, 0.0);
1129 for (
unsigned int i = 0; i < cd->
num_values; ++i) {
1132 mirror_config->set_floats(cd->
path, floats);
1136 mirror_config->set_default_float(cd->
path, f);
1138 mirror_config->set_float(cd->
path, f);
1143 LibLogger::log_warn(
"NetworkConfiguration",
"[mirroring]::inboundReceived: invalid float received");
1147 case MSG_CONFIG_UINT_VALUE:
1152 std::vector<unsigned int> values(cd->
num_values, 0);
1153 for (
unsigned int i = 0; i < cd->
num_values; ++i) {
1156 mirror_config->set_uints(cd->
path, values);
1162 mirror_config->set_default_uint(cd->
path, u);
1164 mirror_config->set_uint(cd->
path, u);
1169 LibLogger::log_warn(
"NetworkConfiguration",
"[mirroring]::inboundReceived: invalid uint received");
1173 case MSG_CONFIG_INT_VALUE:
1179 for (
unsigned int i = 0; i < cd->
num_values; ++i) {
1182 mirror_config->set_ints(cd->
path, values);
1188 mirror_config->set_default_int(cd->
path, i);
1190 mirror_config->set_int(cd->
path, i);
1195 LibLogger::log_warn(
"NetworkConfiguration",
"[mirroring]::inboundReceived: invalid int received");
1199 case MSG_CONFIG_BOOL_VALUE:
1205 for (
unsigned int i = 0; i < cd->
num_values; ++i) {
1206 values[i] = (vs[i] != 0);
1208 mirror_config->set_bools(cd->
path, values);
1214 mirror_config->set_default_bool(cd->
path, (i != 0));
1216 mirror_config->set_bool(cd->
path, (i != 0));
1221 LibLogger::log_warn(
"NetworkConfiguration",
"[mirroring]::inboundReceived: invalid bool received");
1225 case MSG_CONFIG_STRING_VALUE:
1229 std::vector<std::string> values(cd->
num_values,
"");
1231 for (
unsigned int i = 0; i < cd->
num_values; ++i) {
1236 values[i] = std::string(msg_string, vs->
s_length);
1239 mirror_config->set_strings(cd->
path, values);
1246 std::string value = std::string(msg_string, sv->
s_length);
1248 mirror_config->set_default_string(cd->
path, value);
1250 mirror_config->set_string(cd->
path, value);
1255 LibLogger::log_warn(
"NetworkConfiguration",
"[mirroring]::inboundReceived: invalid string received");
1259 case MSG_CONFIG_COMMENT_VALUE:
1263 mirror_config->set_default_comment(cm->
cp.
path, cm->
s);
1265 mirror_config->set_comment(cm->
cp.
path, cm->
s);
1269 LibLogger::log_warn(
"NetworkConfiguration",
"[mirroring]::inboundReceived: invalid string received");
1284 __connected =
false;
1285 __mirror_mode_before_connection_dead = __mirror_mode;
1286 set_mirror_mode(
false);
1295 set_mirror_mode(__mirror_mode_before_connection_dead);
1304 if ( __mirror_mode ) {
1305 mirror_config->add_change_handler(h);
1314 if ( __mirror_mode ) {
1315 mirror_config->rem_change_handler(h);
1327 if ( ! __mirror_mode ) {
1329 if ( ! __connected ) {
1335 __mirror_init_waiting =
true;
1338 __mirror_mode =
true;
1342 MSG_CONFIG_SUBSCRIBE);
1346 if (! __mirror_init_barrier->wait(__mirror_timeout_sec, 0)) {
1348 __mirror_init_waiting =
false;
1349 delete mirror_config;
1353 __mirror_init_waiting =
false;
1357 if ( __mirror_mode ) {
1358 __mirror_mode =
false;
1360 if ( __connected ) {
1362 MSG_CONFIG_UNSUBSCRIBE);
1367 delete mirror_config;
1383 return mutex->try_lock();
1403 if ( __mirror_mode ) {
1404 return mirror_config->iterator();
1406 throw Exception(
"NetworkConfiguration: Iterating only supported in mirror mode");
1421 if ( __mirror_mode ) {
1422 return mirror_config->iterator_default();
1424 throw Exception(
"NetworkConfiguration: Iterating only supported in mirror mode");
1439 if ( __mirror_mode ) {
1440 return mirror_config->iterator_hostspecific();
1442 throw Exception(
"NetworkConfiguration: Iterating only supported in mirror mode");
1450 if ( __mirror_mode ) {
1451 return mirror_config->search(path);
1453 throw Exception(
"NetworkConfiguration: Searching only supported in mirror mode");
1470 iterated_once =
false;
1483 iterated_once =
false;
1498 iterated_once =
false;
1501 if ( (m->
cid() == FAWKES_CID_CONFIGMANAGER) &&
1502 (m->
msgid() >= MSG_CONFIG_VALUE_BEGIN) &&
1503 (m->
msgid() <= MSG_CONFIG_VALUE_END) &&
1509 _path = (
char *)malloc(CONFIG_MSG_PATH_LENGTH + 1);
1510 _path[CONFIG_MSG_PATH_LENGTH] = 0;
1512 strncpy(_path, cd->
path, CONFIG_MSG_PATH_LENGTH);
1523 if ( msg != NULL ) msg->unref();
1524 if ( _path != NULL) free(_path);
1532 if ( (msg == NULL) || iterated_once ) {
1535 iterated_once =
true;
1547 return ( (i != NULL) || (msg != NULL) );
1555 if ( msg == NULL ) {
1570 if ( msg == NULL ) {
1574 switch (msg->msgid()) {
1575 case MSG_CONFIG_FLOAT_VALUE:
return "float";
1576 case MSG_CONFIG_UINT_VALUE:
return "unsigned int";
1577 case MSG_CONFIG_INT_VALUE:
return "int";
1578 case MSG_CONFIG_BOOL_VALUE:
return "bool";
1579 case MSG_CONFIG_STRING_VALUE:
return "string";
1593 if ( msg == NULL ) {
1596 return (msg->msgid() == MSG_CONFIG_FLOAT_VALUE);
1598 return i->is_float();
1607 if ( msg == NULL ) {
1610 return (msg->msgid() == MSG_CONFIG_UINT_VALUE);
1612 return i->is_float();
1621 if ( msg == NULL ) {
1624 return (msg->msgid() == MSG_CONFIG_INT_VALUE);
1635 if ( msg == NULL ) {
1638 return (msg->msgid() == MSG_CONFIG_BOOL_VALUE);
1640 return i->is_bool();
1649 if ( msg == NULL ) {
1652 return (msg->msgid() == MSG_CONFIG_STRING_VALUE);
1654 return i->is_string();
1663 if ( msg == NULL ) {
1669 return i->is_list();
1678 if ( msg == NULL ) {
1684 return i->get_list_size();
1693 if ( msg == NULL ) {
1696 unsigned int msgid = msg->msgid();
1698 case MSG_CONFIG_FLOAT_VALUE:
1699 case MSG_CONFIG_UINT_VALUE:
1700 case MSG_CONFIG_INT_VALUE:
1701 case MSG_CONFIG_BOOL_VALUE:
1702 case MSG_CONFIG_STRING_VALUE:
1710 "iterator to value message");
1713 return i->is_default();
1722 if ( msg == NULL ) {
1725 if (msg->msgid() == MSG_CONFIG_FLOAT_VALUE) {
1735 return i->get_float();
1744 if ( msg == NULL ) {
1747 if (msg->msgid() == MSG_CONFIG_UINT_VALUE) {
1757 return i->get_int();
1766 if ( msg == NULL ) {
1769 if (msg->msgid() == MSG_CONFIG_INT_VALUE) {
1779 return i->get_int();
1788 if ( msg == NULL ) {
1791 if (msg->msgid() == MSG_CONFIG_BOOL_VALUE) {
1801 return i->get_bool();
1810 if ( msg == NULL ) {
1813 if (msg->msgid() == MSG_CONFIG_STRING_VALUE) {
1822 return std::string(msg_string, sv->
s_length);
1825 MSG_CONFIG_STRING_VALUE, msg->msgid());
1828 return i->get_string();
1837 if ( msg == NULL ) {
1840 if (msg->msgid() == MSG_CONFIG_FLOAT_VALUE) {
1848 for (
unsigned int j = 0; j < cd->
num_values; ++j) {
1854 MSG_CONFIG_STRING_VALUE, msg->msgid());
1857 return i->get_floats();
1861 std::vector<unsigned int>
1865 if ( msg == NULL ) {
1868 if (msg->msgid() == MSG_CONFIG_UINT_VALUE) {
1874 std::vector<unsigned int> rv(cd->
num_values, 0);
1876 for (
unsigned int j = 0; j < cd->
num_values; ++j) {
1882 MSG_CONFIG_STRING_VALUE, msg->msgid());
1885 return i->get_uints();
1893 if ( msg == NULL ) {
1896 if (msg->msgid() == MSG_CONFIG_INT_VALUE) {
1904 for (
unsigned int j = 0; j < cd->
num_values; ++j) {
1910 MSG_CONFIG_STRING_VALUE, msg->msgid());
1913 return i->get_ints();
1921 if ( msg == NULL ) {
1924 if (msg->msgid() == MSG_CONFIG_INT_VALUE) {
1932 for (
unsigned int j = 0; j < cd->
num_values; ++j) {
1933 rv[j] = (data[j] != 0);
1938 MSG_CONFIG_STRING_VALUE, msg->msgid());
1941 return i->get_bools();
1945 std::vector<std::string>
1949 if ( msg == NULL ) {
1952 if (msg->msgid() == MSG_CONFIG_STRING_VALUE) {
1957 std::vector<std::string> rv(cd->
num_values,
"");
1960 for (
unsigned int j = 0; j < cd->
num_values; ++j) {
1963 rv[j] = std::string(msg_string, sv->
s_length);
1969 MSG_CONFIG_STRING_VALUE, msg->msgid());
1972 return i->get_strings();
1981 if ( msg == NULL ) {
1983 "invalid iterator");
1985 if (msg->msgid() == MSG_CONFIG_STRING_VALUE) {
1986 return get_string();
1987 }
else if (msg->msgid() == MSG_CONFIG_BOOL_VALUE) {
1988 return get_bool() ?
"true" :
"false";
1989 }
else if (msg->msgid() == MSG_CONFIG_INT_VALUE) {
1991 }
else if (msg->msgid() == MSG_CONFIG_UINT_VALUE) {
1993 }
else if (msg->msgid() == MSG_CONFIG_FLOAT_VALUE) {
1996 throw Exception(
"NetConfValueIterator::get_as_string: unknown type");
1999 return i->get_as_string();
2008 if ( msg == NULL ) {
2011 if (msg->msgid() == MSG_CONFIG_COMMENT_VALUE) {
2018 return i->get_comment();
virtual void set_ints(const char *path, std::vector< int > &i)
Set new value in configuration of type int.
virtual std::vector< int > get_ints() const
Get list of values from configuration which is of type int.
virtual std::string get_as_string() const
Get value as string.
virtual void connection_died(unsigned int id)
Client connection died.
void * payload() const
Get payload buffer.
virtual void try_dump()
Try to dump configuration.
NetworkConfiguration(FawkesNetworkClient *c, unsigned int mirror_timeout_sec=15)
Constructor.
virtual void add_change_handler(ConfigurationChangeHandler *h)
Add a configuration change handler.
virtual bool exists(const char *path)
Check if a given value exists.
virtual std::vector< unsigned int > get_uints() const
Get list of values from configuration which is of type unsigned int.
virtual std::vector< std::string > get_strings(const char *path)
Get list of values from configuration which is of type string.
virtual ValueIterator * iterator()=0
Iterator for all values.
virtual bool is_uint() const
Check if current value is a unsigned int.
virtual bool is_default(const char *path)
Check if a value was read from the default config.
virtual bool is_string(const char *path)
Check if a value is of type string.
NetConfValueIterator()
Constructor.
virtual bool get_bool() const
Get bool value.
virtual void load(const char *file_path)
Load configuration.
virtual std::vector< float > get_floats() const
Get list of values from configuration which is of type float.
Simple Fawkes network client.
virtual bool is_list() const
Check if a value is a list.
virtual ~NetworkConfiguration()
Destructor.
virtual void set_float(const char *path, float f)
Set new value in configuration of type float.
unsigned short int cid() const
Get component ID.
virtual ValueIterator * get_value(const char *path)
Get value from configuration.
virtual bool is_uint(const char *path)
Check if a value is of type unsigned int.
virtual bool is_int() const
Check if current value is a int.
virtual const char * type() const =0
Type of value.
MT * msgge() const
Get correctly casted payload.
virtual void inbound_received(FawkesNetworkMessage *msg, unsigned int id)
Called for incoming messages.
virtual bool next()
Check if there is another element and advance to this if possible.
virtual bool is_bool() const =0
Check if current value is a bool.
Fawkes library namespace.
config_list_entity_header_t * next(size_t *size)
Get next plugin from list.
virtual size_t get_list_size() const
Get number of elements in list value.
virtual std::vector< unsigned int > get_uints(const char *path)
Get list of values from configuration which is of type unsigned int.
Exception()
Constructor for subclasses.
Called method has not been implemented.
config_descriptor_t cp
value descriptor
virtual void set_default_bool(const char *path, bool b)
Set new default value in configuration of type bool.
void register_handler(FawkesNetworkClientHandler *handler, unsigned int component_id)
Register handler.
Interface for configuration change handling.
void lock()
Lock the config.
char path[CONFIG_MSG_PATH_LENGTH]
path to config value.
virtual std::string get_comment() const
Get comment of value.
Representation of a message that is sent over the network.
ValueIterator * iterator()
Iterator for all values.
virtual bool next()=0
Check if there is another element and advance to this if possible.
virtual float get_float() const =0
Get float value.
virtual unsigned int get_uint() const =0
Get unsigned int value.
A NULL pointer was supplied where not allowed.
void unlock()
Unlock the config.
virtual unsigned int get_uint() const
Get unsigned int value.
virtual float get_float(const char *path)
Get value from configuration which is of type float.
virtual std::string get_string(const char *path)
Get value from configuration which is of type string.
virtual bool is_float() const =0
Check if current value is a float.
virtual bool is_float(const char *path)
Check if a value is of type float.
virtual int get_int(const char *path)
Get value from configuration which is of type int.
virtual const char * path() const
Path of value.
virtual std::string get_string() const
Get string value.
virtual std::string get_type(const char *path)
Get type of field.
virtual std::vector< bool > get_bools() const
Get list of values from configuration which is of type bool.
virtual bool is_int() const =0
Check if current value is a int.
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...
virtual bool get_bool(const char *path)
Get value from configuration which is of type bool.
virtual void rem_change_handler(ConfigurationChangeHandler *h)
Remove a configuration change handler.
ValueIterator * iterator_default()
Iterator for all default values.
virtual bool get_bool() const =0
Get bool value.
virtual bool is_bool() const
Check if current value is a bool.
virtual bool is_int(const char *path)
Check if a value is of type int.
virtual int get_int() const
Get int value.
virtual const char * type() const
Type of value.
virtual int get_int() const =0
Get int value.
virtual ~NetConfValueIterator()
Destructor.
bool has_next()
Check if more list elements are available.
virtual bool is_string() const
Check if current value is a string.
virtual std::string get_comment(const char *path)
Get comment of value at given path.
virtual void set_bools(const char *path, std::vector< bool > &b)
Set new value in configuration of type bool.
virtual void set_default_uint(const char *path, unsigned int uint)
Set new default value in configuration of type unsigned int.
virtual bool is_string() const =0
Check if current value is a string.
uint16_t is_default
1 if value is a default value, 0 otherwise, only for get response
virtual void set_comment(const char *path, std::string &comment)
Set new comment for existing value.
Base class for exceptions in Fawkes.
String value header indicating the string length.
virtual void rem_change_handler(ConfigurationChangeHandler *h)
Remove a configuration change handler.
virtual bool valid() const
Check if the current element is valid.
virtual std::vector< int > get_ints(const char *path)
Get list of values from configuration which is of type int.
void ref()
Increment reference count.
virtual void set_floats(const char *path, std::vector< float > &f)
Set new value in configuration of type float.
virtual void set_strings(const char *path, std::vector< std::string > &s)
Set new value in configuration of type string.
config_descriptor_t cp
value descriptor
virtual bool is_uint() const =0
Check if current value is a unsigned int.
virtual std::vector< std::string > get_strings() const
Get list of values from configuration which is of type string.
virtual void erase(const char *path)
Erase the given value from the configuration.
virtual std::string get_string() const =0
Get string value.
virtual void set_uints(const char *path, std::vector< unsigned int > &uint)
Set new value in configuration of type unsigned int.
ValueIterator * iterator_hostspecific()
Iterator for all host-specific values.
virtual void set_default_float(const char *path, float f)
Set new default value in configuration of type float.
uint16_t num_values
Number of valus in list.
virtual void set_mirror_mode(bool mirror)
Enable or disable mirror mode.
virtual void set_bool(const char *path, bool b)
Set new value in configuration of type bool.
virtual const char * path() const =0
Path of value.
virtual bool valid() const =0
Check if the current element is valid.
static void log_warn(const char *component, const char *format,...)
Log warning message.
virtual void copy(Configuration *copyconf)
Copy all values from the given configuration.
virtual unsigned int get_uint(const char *path)
Get value from configuration which is of type unsigned int.
Thrown if the connection died during an operation.
virtual bool is_list(const char *path)
Check if a value is a list.
virtual void unlock()=0
Unlock the config.
virtual void connection_established(unsigned int id)
Client has established a connection.
unsigned short int msgid() const
Get message type ID.
virtual bool is_default() const
Check if current value was read from the default config.
virtual void set_default_int(const char *path, int i)
Set new default value in configuration of type int.
virtual std::string get_default_comment(const char *path)
Get comment of value at given path.
virtual std::vector< bool > get_bools(const char *path)
Get list of values from configuration which is of type bool.
In-memory configuration store.
Iterator interface to iterate over config values.
Network configuration value iterator.
virtual float get_float() const
Get float value.
virtual void set_int(const char *path, int i)
Set new value in configuration of type int.
virtual bool is_default() const =0
Check if current value was read from the default config.
uint16_t s_length
Length of following string.
virtual void add_change_handler(ConfigurationChangeHandler *h)
Add a configuration change handler.
virtual std::vector< float > get_floats(const char *path)
Get list of values from configuration which is of type float.
bool try_lock()
Try to lock the config.
config_descriptor_t cp
value descriptor
virtual bool is_bool(const char *path)
Check if a value is of type bool.
bool connected() const
Check if connection is alive.
MT * msg() const
Get correctly casted payload.
Mutex mutual exclusion lock.
virtual void set_default_comment(const char *path, std::string &comment)
Set new default comment for existing default configuration value.
virtual void deregistered(unsigned int id)
We are no longer registered in Fawkes network client.
Interface for configuration handling.
virtual void set_default_string(const char *path, std::string &s)
Set new default value in configuration of type string.
ValueIterator * search(const char *path)
Iterator with search results.
virtual void set_uint(const char *path, unsigned int uint)
Set new value in configuration of type unsigned int.
static std::string to_string(unsigned int i)
Convert unsigned int value to a string.
CannotEnableMirroringException(const char *msg)
Constructor.
virtual bool is_float() const
Check if current value is a float.
void append(const char *format,...)
Append messages to the message list.
virtual void lock()=0
Lock the config.
size_t payload_size() const
Get payload size.
virtual void set_string(const char *path, std::string &s)
Set new value in configuration of type string.
virtual void erase_default(const char *path)
Erase the given default value from the configuration.