24 #ifndef __CONFIG_NETCONF_H_ 25 #define __CONFIG_NETCONF_H_ 27 #include <config/config.h> 28 #include <netcomm/fawkes/client_handler.h> 29 #include <core/exception.h> 39 class InterruptibleBarrier;
40 class FawkesNetworkClient;
41 class MemoryConfiguration;
60 virtual void load(
const char *file_path);
62 virtual bool exists(
const char *path);
63 virtual bool is_float(
const char *path);
64 virtual bool is_uint(
const char *path);
65 virtual bool is_int(
const char *path);
66 virtual bool is_bool(
const char *path);
68 virtual bool is_list(
const char *path);
72 virtual float get_float(
const char *path);
73 virtual unsigned int get_uint(
const char *path);
74 virtual int get_int(
const char *path);
75 virtual bool get_bool(
const char *path);
76 virtual std::string
get_string(
const char *path);
77 virtual std::vector<float>
get_floats(
const char *path);
78 virtual std::vector<unsigned int>
get_uints(
const char *path);
79 virtual std::vector<int>
get_ints(
const char *path);
80 virtual std::vector<bool>
get_bools(
const char *path);
81 virtual std::vector<std::string>
get_strings(
const char *path);
85 virtual std::string
get_type(
const char *path);
87 virtual void set_float(
const char *path,
float f);
88 virtual void set_uint(
const char *path,
unsigned int uint);
89 virtual void set_int(
const char *path,
int i);
90 virtual void set_bool(
const char *path,
bool b);
91 virtual void set_string(
const char *path, std::string &s);
92 virtual void set_string(
const char *path,
const char *s);
93 virtual void set_floats(
const char *path, std::vector<float> &f);
94 virtual void set_uints(
const char *path, std::vector<unsigned int> &uint);
95 virtual void set_ints(
const char *path, std::vector<int> &i);
96 virtual void set_bools(
const char *path, std::vector<bool> &b);
97 virtual void set_strings(
const char *path, std::vector<std::string> &s);
98 virtual void set_strings(
const char *path, std::vector<const char *> &s);
99 virtual void set_comment(
const char *path, std::string &comment);
100 virtual void set_comment(
const char *path,
const char *comment);
102 virtual void erase(
const char *path);
117 unsigned int id)
throw();
133 virtual bool valid()
const;
135 virtual const char *
path()
const;
136 virtual const char *
type()
const;
140 virtual bool is_int()
const;
149 virtual unsigned int get_uint()
const;
153 virtual std::vector<float>
get_floats()
const;
154 virtual std::vector<unsigned int>
get_uints()
const;
155 virtual std::vector<int>
get_ints()
const;
156 virtual std::vector<bool>
get_bools()
const;
157 virtual std::vector<std::string>
get_strings()
const;
181 void send_get(
const char *path,
unsigned int msgid,
unsigned int expected_reply);
183 void set_value_internal(
unsigned int msg_type,
const char *path, uint16_t num_values,
184 size_t data_size,
void *data);
186 void erase_internal(
const char *path,
bool is_default);
192 bool __mirror_init_waiting;
196 bool __mirror_mode_before_connection_dead;
197 unsigned int __mirror_timeout_sec;
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.
virtual void try_dump()
Try to dump configuration.
Message handler for FawkesNetworkClient.
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 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.
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 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.
Fawkes library namespace.
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.
virtual void set_default_bool(const char *path, bool b)
Set new default value in configuration of type bool.
Interface for configuration change handling.
void lock()
Lock the config.
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.
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 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.
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 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 ~NetConfValueIterator()
Destructor.
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 void set_comment(const char *path, std::string &comment)
Set new comment for existing value.
Base class for exceptions in Fawkes.
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.
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.
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 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.
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 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.
virtual bool is_list(const char *path)
Check if a value is a list.
virtual void connection_established(unsigned int id)
Client has established a connection.
Thrown if enabling mirror mode failed.
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 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.
virtual bool is_bool(const char *path)
Check if a value is of type bool.
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.
CannotEnableMirroringException(const char *msg)
Constructor.
virtual bool is_float() const
Check if current value is a float.
Remote configuration via Fawkes net.
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.