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>
38 class InterruptibleBarrier;
39 class FawkesNetworkClient;
40 class SQLiteConfiguration;
59 virtual void load(
const char *filename,
const char *defaults_filename,
60 const char *
tag = NULL);
62 virtual void tag(
const char *
tag);
63 virtual std::list<std::string>
tags();
65 virtual bool exists(
const char *path);
66 virtual bool is_float(
const char *path);
67 virtual bool is_uint(
const char *path);
68 virtual bool is_int(
const char *path);
69 virtual bool is_bool(
const char *path);
74 virtual float get_float(
const char *path);
75 virtual unsigned int get_uint(
const char *path);
76 virtual int get_int(
const char *path);
77 virtual bool get_bool(
const char *path);
78 virtual std::string
get_string(
const char *path);
82 virtual std::string
get_type(
const char *path);
84 virtual void set_float(
const char *path,
float f);
85 virtual void set_uint(
const char *path,
unsigned int uint);
86 virtual void set_int(
const char *path,
int i);
87 virtual void set_bool(
const char *path,
bool b);
88 virtual void set_string(
const char *path, std::string &s);
89 virtual void set_string(
const char *path,
const char *s);
90 virtual void set_comment(
const char *path, std::string &comment);
91 virtual void set_comment(
const char *path,
const char *comment);
93 virtual void erase(
const char *path);
108 unsigned int id)
throw();
124 virtual bool valid()
const;
126 virtual const char *
path()
const;
127 virtual const char *
type()
const;
131 virtual bool is_int()
const;
138 virtual unsigned int get_uint()
const;
163 void send_get(
const char *path,
unsigned int msgid);
165 void set_float_internal(
unsigned int msg_type,
const char *path,
float f);
166 void set_uint_internal(
unsigned int msg_type,
const char *path,
168 void set_int_internal(
unsigned int msg_type,
const char *path,
int i);
169 void set_bool_internal(
unsigned int msg_type,
const char *path,
bool b);
170 void set_string_internal(
unsigned int msg_type,
const char *path,
172 void set_comment_internal(
unsigned int msg_type,
const char *path,
175 void erase_internal(
const char *path,
bool is_default);
184 bool __mirror_mode_before_connection_dead;
185 unsigned int __mirror_timeout_sec;
virtual std::string get_comment() const
Get comment of value.
virtual void connection_died(unsigned int id)
Client connection died.
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 bool is_default() const
Check if current value was read from the default config.
virtual std::list< std::string > tags()
List of tags.
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.
Simple Fawkes network client.
virtual ~NetworkConfiguration()
Destructor.
virtual void set_float(const char *path, float f)
Set new value in configuration of type float.
virtual void tag(const char *tag)
Tag this configuration version.
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.
Configuration storage using SQLite.
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_int() const
Check if current value is a int.
virtual void set_default_bool(const char *path, bool b)
Set new default value in configuration of type bool.
virtual std::string get_as_string() const
Get value as string.
virtual void load(const char *filename, const char *defaults_filename, const char *tag=NULL)
Load configuration.
Interface for configuration change handling.
void lock()
Lock the config.
Representation of a message that is sent over the network.
ValueIterator * iterator()
Iterator for all values.
void unlock()
Unlock the config.
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 get_bool() const
Get bool value.
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 std::string get_type(const char *path)
Get type of field.
virtual bool is_bool() const
Check if current value is a bool.
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...
virtual bool valid() const
Check if the current element is valid.
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_int(const char *path)
Check if a value is of type int.
virtual ~NetConfValueIterator()
Destructor.
virtual int get_int() const
Get int value.
virtual std::string get_comment(const char *path)
Get comment of value at given path.
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 unsigned int get_uint() const
Get unsigned int value.
virtual void erase(const char *path)
Erase the given value from the configuration.
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 bool is_float() const
Check if current value is a 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 void connection_established(unsigned int id)
Client has established a connection.
Thrown if enabling mirror mode failed.
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.
Iterator interface to iterate over config values.
Network configuration value iterator.
virtual std::string get_string() const
Get string value.
virtual void set_int(const char *path, int i)
Set new value in configuration of type int.
virtual float get_float() const
Get float value.
virtual const char * path() const
Path of value.
bool try_lock()
Try to lock the config.
virtual bool is_uint() const
Check if current value is a unsigned int.
virtual bool is_bool(const char *path)
Check if a value is of type bool.
virtual const char * type() const
Type of value.
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 bool is_string() const
Check if current value is a string.
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.
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.