24 #include <config/net_list_content.h>
25 #include <core/exceptions/software.h>
26 #include <netcomm/fawkes/component_ids.h>
27 #include <netcomm/utils/dynamic_buffer.h>
61 if (component_id != FAWKES_CID_CONFIGMANAGER) {
65 void * config_list_payload = (
void *)((
size_t)
payload +
sizeof(msg));
84 copy_data_vector(T *in, T *out,
const size_t num_values)
86 for (
unsigned int j = 0; j < num_values; ++j) {
100 size_t data_size = 0;
104 memset(&cle, 0,
sizeof(cle));
105 strncpy(cle.
cp.
path, i->
path(), CONFIG_MSG_PATH_LENGTH - 1);
106 cle.
type = MSG_CONFIG_FLOAT_VALUE;
111 cle.
type = MSG_CONFIG_UINT_VALUE;
112 data_size = num_values *
sizeof(uint32_t);
114 cle.
type = MSG_CONFIG_INT_VALUE;
115 data_size = num_values *
sizeof(int32_t);
117 cle.
type = MSG_CONFIG_BOOL_VALUE;
118 data_size = num_values *
sizeof(int32_t);
120 cle.
type = MSG_CONFIG_FLOAT_VALUE;
121 data_size = num_values *
sizeof(float);
123 cle.
type = MSG_CONFIG_STRING_VALUE;
125 std::vector<std::string> values = i->
get_strings();
126 for (
unsigned int j = 0; j < values.size(); ++j) {
133 throw Exception(
"Invalid type of config iterator value (%s)", i->
path());
141 copy_data_vector(&i->
get_uints()[0], (uint32_t *)(data +
sizeof(cle)), num_values);
143 *((uint32_t *)(data +
sizeof(cle))) = i->
get_uint();
147 copy_data_vector(&i->
get_ints()[0], (int32_t *)(data +
sizeof(cle)), num_values);
149 *((int32_t *)(data +
sizeof(cle))) = i->
get_int();
153 std::vector<bool> values = i->
get_bools();
154 int32_t * msg_values = (int32_t *)(data +
sizeof(cle));
155 for (
unsigned int j = 0; j < values.size(); ++j) {
156 msg_values[j] = values[j] ? 1 : 0;
160 *((int32_t *)(data +
sizeof(cle))) = i->
get_bool() ? 1 : 0;
164 copy_data_vector(&i->
get_floats()[0], (
float *)(data +
sizeof(cle)), num_values);
166 *((
float *)(data +
sizeof(cle))) = i->
get_float();
170 std::vector<std::string> values = i->
get_strings();
171 char * tmpdata = (
char *)data +
sizeof(cle);
172 for (
unsigned int j = 0; j < values.size(); ++j) {
176 strcpy(msg_string, values[j].c_str());
187 config_list->
append(data,
sizeof(cle) + data_size);
227 void *tmp = config_list->
next(size);
bool has_next()
Check if more list elements are available.
virtual ~ConfigListContent()
Destructor.
void append(Configuration::ValueIterator *i)
Append from iterator.
ConfigListContent()
Constructor.
void reset_iterator()
Reset iterator.
virtual void serialize()
Serialize message content.
config_list_entity_header_t * next(size_t *size)
Get next plugin from list.
Iterator interface to iterate over config values.
virtual bool is_list() const =0
Check if a value is a list.
virtual bool is_uint() const =0
Check if current value is a unsigned int.
virtual std::vector< unsigned int > get_uints() const =0
Get list of values from configuration which is of type unsigned int.
virtual const char * path() const =0
Path of value.
virtual bool get_bool() const =0
Get bool value.
virtual unsigned int get_uint() const =0
Get unsigned int value.
virtual std::vector< bool > get_bools() const =0
Get list of values from configuration which is of type bool.
virtual float get_float() const =0
Get float value.
virtual bool is_float() const =0
Check if current value is a float.
virtual bool is_int() const =0
Check if current value is a int.
virtual bool is_default() const =0
Check if current value was read from the default config.
virtual bool is_string() const =0
Check if current value is a string.
virtual bool is_bool() const =0
Check if current value is a bool.
virtual int get_int() const =0
Get int value.
virtual std::vector< std::string > get_strings() const =0
Get list of values from configuration which is of type string.
virtual size_t get_list_size() const =0
Get number of elements in list value.
virtual std::string get_string() const =0
Get string value.
virtual std::vector< int > get_ints() const =0
Get list of values from configuration which is of type int.
virtual std::vector< float > get_floats() const =0
Get list of values from configuration which is of type float.
Dynamically growing buffer.
size_t buffer_size()
Get buffer size.
void append(const void *data, size_t data_size)
Append data.
void reset_iterator()
Reset iterator.
bool has_next()
Check if another element is available.
void * next(size_t *size)
Get next buffer.
void * buffer()
Get pointer to buffer.
Base class for exceptions in Fawkes.
void copy_payload(size_t offset, const void *buf, size_t len)
Copy payload into payload buffer to a specified offset.
virtual size_t payload_size()
Return payload size.
size_t _payload_size
Payloda size.
void * _payload
Pointer to payload.
virtual void * payload()
Return pointer to payload.
Fawkes library namespace.
uint16_t num_values
Number of valus in list.
uint16_t is_default
1 if value is a default value, 0 otherwise, only for get response
char path[CONFIG_MSG_PATH_LENGTH]
path to config value.
dynamic_list_t config_list
DynamicBuffer for list.
String value header indicating the string length.
uint16_t s_length
Length of following string.