24 #ifndef _CONFIG_NETCONF_H_
25 #define _CONFIG_NETCONF_H_
27 #include <config/config.h>
28 #include <core/exception.h>
29 #include <netcomm/fawkes/client_handler.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);
134 virtual bool valid()
const;
136 virtual const char *
path()
const;
137 virtual const char *
type()
const;
141 virtual bool is_int()
const;
150 virtual unsigned int get_uint()
const;
154 virtual std::vector<float>
get_floats()
const;
155 virtual std::vector<unsigned int>
get_uints()
const;
156 virtual std::vector<int>
get_ints()
const;
157 virtual std::vector<bool>
get_bools()
const;
158 virtual std::vector<std::string>
get_strings()
const;
182 void send_get(
const char *path,
unsigned int msgid,
unsigned int expected_reply);
184 void set_value_internal(
unsigned int msg_type,
190 void erase_internal(
const char *path,
bool is_default);
195 bool mirror_init_waiting_;
199 bool mirror_mode_before_connection_dead_;
200 unsigned int mirror_timeout_sec_;
Thrown if enabling mirror mode failed.
CannotEnableMirroringException(const char *msg)
Constructor.
Interface for configuration change handling.
Iterator interface to iterate over config values.
Interface for configuration handling.
Base class for exceptions in Fawkes.
Message handler for FawkesNetworkClient.
Simple Fawkes network client.
Representation of a message that is sent over the network.
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...
In-memory configuration store.
Mutex mutual exclusion lock.
Network configuration value iterator.
virtual bool is_bool() const
Check if current value is a bool.
virtual std::vector< float > get_floats() const
Get list of values from configuration which is of type float.
virtual ~NetConfValueIterator()
Destructor.
virtual std::string get_as_string() const
Get value as string.
virtual size_t get_list_size() const
Get number of elements in list value.
virtual std::vector< unsigned int > get_uints() const
Get list of values from configuration which is of type unsigned int.
virtual bool is_string() const
Check if current value is a string.
virtual std::vector< bool > get_bools() const
Get list of values from configuration which is of type bool.
virtual bool is_int() const
Check if current value is a int.
virtual bool valid() const
Check if the current element is valid.
virtual bool get_bool() const
Get bool value.
virtual std::string get_string() const
Get string value.
virtual float get_float() const
Get float value.
virtual bool is_list() const
Check if a value is a list.
virtual std::vector< std::string > get_strings() const
Get list of values from configuration which is of type string.
virtual bool is_float() const
Check if current value is a float.
virtual const char * type() const
Type of value.
NetConfValueIterator()
Constructor.
virtual std::string get_comment() const
Get comment of value.
virtual bool is_uint() const
Check if current value is a unsigned int.
virtual bool next()
Check if there is another element and advance to this if possible.
virtual const char * path() const
Path of value.
virtual unsigned int get_uint() const
Get unsigned int value.
virtual std::vector< int > get_ints() const
Get list of values from configuration which is of type int.
virtual int get_int() const
Get int value.
virtual bool is_default() const
Check if current value was read from the default config.
Remote configuration via Fawkes net.
virtual bool is_float(const char *path)
Check if a value is of type float.
virtual void add_change_handler(ConfigurationChangeHandler *h)
Add a configuration change handler.
ValueIterator * iterator_default()
Iterator for all default values.
virtual void erase_default(const char *path)
Erase the given default value from the configuration.
bool try_lock()
Try to lock the config.
virtual std::vector< unsigned int > get_uints(const char *path)
Get list of values from configuration which is of type unsigned int.
virtual std::string get_comment(const char *path)
Get comment of value at given path.
virtual std::string get_string(const char *path)
Get value from configuration which is of type string.
NetworkConfiguration(FawkesNetworkClient *c, unsigned int mirror_timeout_sec=15)
Constructor.
virtual int get_int(const char *path)
Get value from configuration which is of type int.
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::string get_type(const char *path)
Get type of field.
virtual bool exists(const char *path)
Check if a given value exists.
ValueIterator * iterator()
Iterator for all values.
void lock()
Lock the config.
virtual void erase(const char *path)
Erase the given value from the configuration.
void unlock()
Unlock the config.
virtual void set_int(const char *path, int i)
Set new value in configuration of type int.
virtual void connection_established(unsigned int id) noexcept
Client has established a connection.
virtual void load(const char *file_path)
Load configuration.
virtual bool is_list(const char *path)
Check if a value is a list.
ValueIterator * iterator_hostspecific()
Iterator for all host-specific values.
ValueIterator * search(const char *path)
Iterator with search results.
virtual unsigned int get_uint(const char *path)
Get value from configuration which is of type unsigned int.
virtual void set_bool(const char *path, bool b)
Set new value in configuration of type bool.
virtual void set_default_float(const char *path, float f)
Set new default value in configuration of type float.
virtual bool is_uint(const char *path)
Check if a value is of type unsigned int.
virtual void set_mirror_mode(bool mirror)
Enable or disable mirror mode.
virtual void inbound_received(FawkesNetworkMessage *msg, unsigned int id) noexcept
Called for incoming messages.
virtual void set_default_string(const char *path, std::string &s)
Set new default value in configuration of type string.
virtual void set_default_bool(const char *path, bool b)
Set new default 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 deregistered(unsigned int id) noexcept
We are no longer registered in Fawkes network client.
virtual bool is_bool(const char *path)
Check if a value is of type bool.
virtual std::vector< bool > get_bools(const char *path)
Get list of values from configuration which is of type bool.
virtual void set_float(const char *path, float f)
Set new value in configuration of type float.
virtual std::vector< std::string > get_strings(const char *path)
Get list of values from configuration which is of type string.
virtual void set_strings(const char *path, std::vector< std::string > &s)
Set new value in configuration of type string.
virtual ~NetworkConfiguration()
Destructor.
virtual std::vector< int > get_ints(const char *path)
Get list of values from configuration which is of type int.
virtual bool is_string(const char *path)
Check if a value is of type string.
virtual void set_comment(const char *path, std::string &comment)
Set new comment for existing value.
virtual bool is_default(const char *path)
Check if a value was read from the default config.
virtual void set_bools(const char *path, std::vector< bool > &b)
Set new value in configuration of type bool.
virtual void set_uints(const char *path, std::vector< unsigned int > &uint)
Set new value in configuration of type unsigned int.
virtual void rem_change_handler(ConfigurationChangeHandler *h)
Remove a configuration change handler.
virtual void set_ints(const char *path, std::vector< int > &i)
Set new value in configuration of type int.
virtual void set_default_comment(const char *path, std::string &comment)
Set new default comment for existing default configuration value.
virtual void try_dump()
Try to dump configuration.
virtual bool get_bool(const char *path)
Get value from configuration which is of type bool.
virtual bool is_int(const char *path)
Check if a value is of type int.
virtual void set_uint(const char *path, unsigned int uint)
Set new value in configuration of type unsigned int.
virtual float get_float(const char *path)
Get value from configuration which is of type float.
virtual void connection_died(unsigned int id) noexcept
Client connection died.
virtual void copy(Configuration *copyconf)
Copy all values from the given configuration.
virtual ValueIterator * get_value(const char *path)
Get value from configuration.
virtual std::vector< float > get_floats(const char *path)
Get list of values from configuration which is of type float.
virtual void set_string(const char *path, std::string &s)
Set new value in configuration of type string.
virtual void set_floats(const char *path, std::vector< float > &f)
Set new value in configuration of type float.
Fawkes library namespace.