Classes | Public Member Functions

fawkes::NetworkConfiguration Class Reference

Remote configuration via Fawkes net. More...

#include <>>

Inheritance diagram for fawkes::NetworkConfiguration:
Inheritance graph
[legend]

List of all members.

Classes

class  NetConfValueIterator
 Network configuration value iterator. More...

Public Member Functions

 NetworkConfiguration (FawkesNetworkClient *c, unsigned int mirror_timeout_sec=15)
 Constructor.
virtual ~NetworkConfiguration ()
 Destructor.
virtual void copy (Configuration *copyconf)
 Copy all values from the given configuration.
virtual void add_change_handler (ConfigurationChangeHandler *h)
virtual void rem_change_handler (ConfigurationChangeHandler *h)
virtual void load (const char *filename, const char *defaults_filename, const char *tag=NULL)
 Load configuration.
virtual void tag (const char *tag)
virtual std::list< std::string > tags ()
virtual bool exists (const char *path)
virtual bool is_float (const char *path)
virtual bool is_uint (const char *path)
virtual bool is_int (const char *path)
virtual bool is_bool (const char *path)
virtual bool is_string (const char *path)
virtual bool is_default (const char *path)
virtual float get_float (const char *path)
virtual unsigned int get_uint (const char *path)
virtual int get_int (const char *path)
virtual bool get_bool (const char *path)
virtual std::string get_string (const char *path)
virtual ValueIterator * get_value (const char *path)
virtual std::string get_comment (const char *path)
virtual std::string get_default_comment (const char *path)
virtual std::string get_type (const char *path)
 Get type of field.
virtual void set_float (const char *path, float f)
virtual void set_uint (const char *path, unsigned int uint)
virtual void set_int (const char *path, int i)
virtual void set_bool (const char *path, bool b)
virtual void set_string (const char *path, std::string &s)
virtual void set_string (const char *path, const char *s)
virtual void set_comment (const char *path, std::string &comment)
virtual void set_comment (const char *path, const char *comment)
virtual void erase (const char *path)
virtual void set_default_float (const char *path, float f)
virtual void set_default_uint (const char *path, unsigned int uint)
virtual void set_default_int (const char *path, int i)
virtual void set_default_bool (const char *path, bool b)
virtual void set_default_string (const char *path, std::string &s)
virtual void set_default_string (const char *path, const char *s)
virtual void set_default_comment (const char *path, std::string &comment)
virtual void set_default_comment (const char *path, const char *comment)
virtual void erase_default (const char *path)
virtual void deregistered (unsigned int id) throw ()
 We are no longer registered in Fawkes network client.
virtual void inbound_received (FawkesNetworkMessage *msg, unsigned int id) throw ()
 Called for incoming messages.
virtual void connection_died (unsigned int id) throw ()
 Client connection died.
virtual void connection_established (unsigned int id) throw ()
 Client has established a connection.
virtual void set_mirror_mode (bool mirror)
 Enable or disable mirror mode.
ValueIterator * iterator ()
ValueIterator * iterator_default ()
ValueIterator * iterator_hostspecific ()
ValueIterator * search (const char *path)
void lock ()
bool try_lock ()
void unlock ()

Detailed Description

Remote configuration via Fawkes net.

This implementation of the Configuration interface allows for remote access to a Fawkes process implemented using the ConfigurationManager.

The network configuration can operator in two modes. In mirror and in non-mirror mode. The non-mirror mode is recommended if only a few operations have to be carried out like getting only a very few values or setting a single value. The mirror mode is for longer usage periods and on-the-fly updates. In mirror mode the complete configuration is copied once from the Fawkes process and then all updates are incorporated into the local database. You can register change handlers to be notified as soon as someone modifies a value.

Definition at line 48 of file netconf.h.


Constructor & Destructor Documentation

fawkes::NetworkConfiguration::NetworkConfiguration ( FawkesNetworkClient c,
unsigned int  mirror_timeout_sec = 15 
)

Constructor.

Parameters:
c Fawkes network client (thread).
mirror_timeout_sec timeout in seconds for initiating mirroring

Definition at line 77 of file netconf.cpp.

References fawkes::Exception::append(), fawkes::FawkesNetworkClient::connected(), and fawkes::FawkesNetworkClient::register_handler().

fawkes::NetworkConfiguration::~NetworkConfiguration (  )  [virtual]

Member Function Documentation

void fawkes::NetworkConfiguration::connection_died ( unsigned int  id  )  throw () [virtual]

Client connection died.

This method is used to inform handlers that the connection has died for any reason. No more data can be send and no more messages should be enqueued because it is unclear when they would be sent.

Parameters:
id the id of the calling client

Implements fawkes::FawkesNetworkClientHandler.

Definition at line 1227 of file netconf.cpp.

void fawkes::NetworkConfiguration::connection_established ( unsigned int  id  )  throw () [virtual]

Client has established a connection.

Whenever the client establishes a connection this is signaled to handlers with this method. You can register to a client at any time, you may even enqueue messages to a client while the connection is dead. If the client at some point gets connected again, the messages will then be send out in one go. You should use this in your application though to only send data if the connection is alive and you should let the user know about the connection status.

Parameters:
id the id of the calling client

Implements fawkes::FawkesNetworkClientHandler.

Definition at line 1237 of file netconf.cpp.

void fawkes::NetworkConfiguration::copy ( Configuration copyconf  )  [virtual]
void fawkes::NetworkConfiguration::deregistered ( unsigned int  id  )  throw () [virtual]

We are no longer registered in Fawkes network client.

Ignored.

Parameters:
id the id of the calling client

Implements fawkes::FawkesNetworkClientHandler.

Definition at line 1014 of file netconf.cpp.

std::string fawkes::NetworkConfiguration::get_type ( const char *  path  )  [virtual]

Get type of field.

Parameters:
path path
Returns:
string of type

Definition at line 200 of file netconf.cpp.

References fawkes::SQLiteConfiguration::get_type(), fawkes::Mutex::lock(), fawkes::Configuration::ValueIterator::type(), and fawkes::Mutex::unlock().

void fawkes::NetworkConfiguration::inbound_received ( FawkesNetworkMessage m,
unsigned int  id 
) throw () [virtual]
void fawkes::NetworkConfiguration::load ( const char *  name,
const char *  defaults_name,
const char *  tag = NULL 
) [virtual]

Load configuration.

This is a noop for the NetworkConfiguration.

Parameters:
name name of the host-based database. This should be a name of the form hostname.db, where hostname is the unqualified part of the hostname.
defaults_name name of the default database. Should be defaults.db
tag optional tag to restore

Definition at line 118 of file netconf.cpp.

void fawkes::NetworkConfiguration::set_mirror_mode ( bool  mirror  )  [virtual]

Enable or disable mirror mode.

Parameters:
mirror true to enable mirror mode, false to disable

Definition at line 1269 of file netconf.cpp.

References fawkes::FawkesNetworkClient::enqueue(), fawkes::SQLiteConfiguration::load(), fawkes::Mutex::lock(), fawkes::Mutex::unlock(), and fawkes::InterruptibleBarrier::wait().

Referenced by ConfigTreeView::set_network_client(), and ~NetworkConfiguration().


The documentation for this class was generated from the following files: