24 #include <config/net_list_content.h> 26 #include <netcomm/utils/dynamic_buffer.h> 27 #include <netcomm/fawkes/component_ids.h> 28 #include <core/exceptions/software.h> 61 if ( component_id != FAWKES_CID_CONFIGMANAGER ) {
65 void *config_list_payload = (
void *)((
size_t)payload +
sizeof(msg));
67 payload_size -
sizeof(msg));
85 copy_data_vector(T *in, T *out,
const size_t num_values)
87 for (
unsigned int j = 0; j < num_values; ++j) {
101 size_t data_size = 0;
105 memset(&cle, 0,
sizeof(cle));
106 strncpy(cle.
cp.
path, i->
path(), CONFIG_MSG_PATH_LENGTH);
107 cle.
type = MSG_CONFIG_FLOAT_VALUE;
112 cle.
type = MSG_CONFIG_UINT_VALUE;
113 data_size = num_values *
sizeof(uint32_t);
114 }
else if ( i->
is_int() ) {
115 cle.
type = MSG_CONFIG_INT_VALUE;
116 data_size = num_values *
sizeof(int32_t);
118 cle.
type = MSG_CONFIG_BOOL_VALUE;
119 data_size = num_values *
sizeof(int32_t);
121 cle.
type = MSG_CONFIG_FLOAT_VALUE;
122 data_size = num_values *
sizeof(float);
124 cle.
type = MSG_CONFIG_STRING_VALUE;
126 std::vector<std::string> values = i->
get_strings();
127 for (
unsigned int j = 0; j < values.size(); ++j) {
134 throw Exception(
"Invalid type of config iterator value (%s)", i->
path());
142 copy_data_vector(&i->
get_uints()[0], (uint32_t *)(data +
sizeof(cle)), num_values);
144 *((uint32_t *)(data +
sizeof(cle))) = i->
get_uint();
146 }
else if ( i->
is_int() ) {
148 copy_data_vector(&i->
get_ints()[0], (int32_t *)(data +
sizeof(cle)), num_values);
150 *((int32_t *)(data +
sizeof(cle))) = i->
get_int();
154 std::vector<bool> values = i->
get_bools();
155 int32_t *msg_values = (int32_t *)(data +
sizeof(cle));
156 for (
unsigned int j = 0; j < values.size(); ++j) {
157 msg_values[j] = values[j] ? 1 : 0;
161 *((int32_t *)(data +
sizeof(cle))) = i->
get_bool() ? 1 : 0;
165 copy_data_vector(&i->
get_floats()[0], (
float *)(data +
sizeof(cle)), num_values);
167 *((
float *)(data +
sizeof(cle))) = i->
get_float();
171 std::vector<std::string> values = i->
get_strings();
172 char *tmpdata = (
char *)data +
sizeof(cle);
173 for (
unsigned int j = 0; j < values.size(); ++j) {
177 strcpy(msg_string, values[j].c_str());
188 config_list->
append(data,
sizeof(cle) + data_size);
232 void *tmp = config_list->
next(size);
void * _payload
Pointer to payload.
size_t _payload_size
Payloda size.
virtual std::vector< bool > get_bools() const =0
Get list of values from configuration which is of type bool.
void append(Configuration::ValueIterator *i)
Append from iterator.
virtual std::vector< std::string > get_strings() const =0
Get list of values from configuration which is of type string.
virtual std::vector< float > get_floats() const =0
Get list of values from configuration which is of type float.
virtual ~ConfigListContent()
Destructor.
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.
void * buffer()
Get pointer to buffer.
char path[CONFIG_MSG_PATH_LENGTH]
path to config value.
virtual std::vector< int > get_ints() const =0
Get list of values from configuration which is of type int.
virtual float get_float() const =0
Get float value.
virtual unsigned int get_uint() const =0
Get unsigned int value.
virtual size_t get_list_size() const =0
Get number of elements in list value.
virtual bool is_float() const =0
Check if current value is a float.
dynamic_list_t config_list
DynamicBuffer for list.
virtual bool is_int() const =0
Check if current value is a int.
virtual bool get_bool() const =0
Get bool value.
bool has_next()
Check if another element is available.
size_t buffer_size()
Get buffer size.
virtual void serialize()
Serialize message content.
ConfigListContent()
Constructor.
virtual int get_int() const =0
Get int value.
bool has_next()
Check if more list elements are available.
virtual bool is_string() const =0
Check if current value is a string.
virtual std::vector< unsigned int > get_uints() const =0
Get list of values from configuration which is of type unsigned int.
uint16_t is_default
1 if value is a default value, 0 otherwise, only for get response
Base class for exceptions in Fawkes.
String value header indicating the string length.
virtual bool is_uint() const =0
Check if current value is a unsigned int.
virtual bool is_list() const =0
Check if a value is a list.
virtual std::string get_string() const =0
Get string value.
virtual void * payload()
Return pointer to payload.
uint16_t num_values
Number of valus in list.
virtual const char * path() const =0
Path of value.
void copy_payload(size_t offset, const void *buf, size_t len)
Copy payload into payload buffer to a specified offset.
Dynamically growing buffer.
virtual size_t payload_size()
Return payload size.
Iterator interface to iterate over config values.
void reset_iterator()
Reset iterator.
virtual bool is_default() const =0
Check if current value was read from the default config.
uint16_t s_length
Length of following string.
void append(const void *data, size_t data_size)
Append data.
void * next(size_t *size)
Get next buffer.
void reset_iterator()
Reset iterator.