Bayonne2 / Common C++ 2 Framework
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions
ost::ReconfigKeydata Class Reference

Bayonne specific reloaded keydata class. More...

#include <bayonne.h>

Inheritance diagram for ost::ReconfigKeydata:
Inheritance graph
[legend]
Collaboration diagram for ost::ReconfigKeydata:
Collaboration graph
[legend]

Public Member Functions

const char * getInitial (const char *id)
 
void setInitial (const char *id, const char *val)
 
 ReconfigKeydata (const char *keypath, Keydata::Define *def=NULL)
 
const char * getString (const char *key, char *buf, size_t size)
 
timeout_t getSecTimer (const char *key)
 
timeout_t getMsecTimer (const char *key)
 
long getValue (const char *key)
 
bool isKey (const char *key)
 
bool getBoolean (const char *key)
 
const char * getString (const char *id)
 
const char * getString (const char *sym, const char *def=NULL)
 Get a string value, with an optional default if missing. More...
 
unsigned getIndex (char **data, unsigned max)
 Get an index array of ALL keywords that are stored by the current keydata object. More...
 
void load (const char *keypath)
 Load additional key values into the currrent object from the specfied config source (a config file/section pair). More...
 
void load (Define *pairs)
 Load default keywords into the current object. More...
 
void loadPrefix (const char *prefix, const char *keypath)
 Load additional key values into the currrent object from the specfied config source (a config file/section pair). More...
 
void loadFile (const char *filepath, const char *keys=NULL, const char *pre=NULL)
 Load additional keys into the current object using a real filename that is directly passed rather than a computed key path. More...
 
void unlink (void)
 Unlink the keydata object from the cache file stream. More...
 
int getCount (const char *sym)
 Get a count of the number of data "values" that is associated with a specific keyword. More...
 
unsigned getCount (void)
 Get the count of keyword indexes that are actually available so one can allocate a table to receive getIndex. More...
 
const char * getFirst (const char *sym)
 Get the first data value for a given keyword. More...
 
const char * getLast (const char *sym)
 Get the last (most recently set) value for a given keyword. More...
 
long getLong (const char *sym, long def=0)
 Get a long value, with an optional default if missing. More...
 
bool getBool (const char *key)
 Get a bool value. More...
 
double getDouble (const char *key, double def=0.)
 Get a floating value. More...
 
void setValue (const char *sym, const char *data)
 Set (replace) the value of a given keyword. More...
 
const char *const * getList (const char *sym)
 Return a list of all values set for the given keyword returned in order. More...
 
void clrValue (const char *sym)
 Clear all values associated with a given keyword. More...
 
const char * operator[] (const char *keyword)
 A convient notation for accessing the keydata as an associative array of keyword/value pairs through the [] operator. More...
 

Static Public Member Functions

static void end (void)
 static member to end keydata i/o allocations. More...
 

Protected Member Functions

const char * updatedString (const char *id)
 
long updatedValue (const char *id)
 
timeout_t updatedSecTimer (const char *id)
 
timeout_t updatedMsecTimer (const char *id)
 
bool updatedBoolean (const char *id)
 
KeysymgetSymbol (const char *sym, bool create)
 
virtual void * first (size_t size)
 Allocate first workspace from paged memory. More...
 
char * first (char *str)
 Allocate a string from the memory pager pool and copy the string into it's new memory area. More...
 
virtual void * alloc (size_t size)
 Allocate memory from either the currently active page, or allocate a new page for the object. More...
 
char * alloc (const char *str)
 Allocate a string from the memory pager pool and copy the string inti it's new memory area. More...
 
void purge (void)
 purge the current memory pool. More...
 
void clean (void)
 Clean for memory cleanup before exiting. More...
 
int getPages (void)
 Return the total number of pages that have been allocated for this memory pool. More...
 
virtual void updateConfig (Keydata *keydata)
 
void readLock (void)
 Aquire a read lock for the current object. More...
 
void writeLock (void)
 Aquire a write lock for the current object. More...
 
bool tryReadLock (void)
 Attempt read lock for current object. More...
 
bool tryWriteLock (void)
 Attempt write lock for current object. More...
 
void unlock (void)
 Release any held locks. More...
 

Static Protected Member Functions

static void reload (void)
 

Detailed Description

Bayonne specific reloaded keydata class.

This class is used for keydata items which can be reloaded from the config file during runtime while using keydata base for core compatibility and defaults.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org Dynamically reloadable key data class.

Definition at line 218 of file bayonne.h.

Constructor & Destructor Documentation

ost::ReconfigKeydata::ReconfigKeydata ( const char *  keypath,
Keydata::Define def = NULL 
)

Member Function Documentation

virtual void* MemPager::alloc ( size_t  size)
protectedvirtualinherited

Allocate memory from either the currently active page, or allocate a new page for the object.

Parameters
sizesize of memory to allocate.
Returns
pointer to allocated memory.

Reimplemented in SharedMemPager.

char* MemPager::alloc ( const char *  str)
protectedinherited

Allocate a string from the memory pager pool and copy the string inti it's new memory area.

This checks only the last active page for available space before allocating a new page.

Parameters
strstring to allocate and copy into paged memory pool.
Returns
copy of string from allocated memory.
void MemPager::clean ( void  )
protectedinherited

Clean for memory cleanup before exiting.

void Keydata::clrValue ( const char *  sym)
inherited

Clear all values associated with a given keyword.

This does not de-allocate the keyword from memory, however.

Returns
keyword name to clear.
static void Keydata::end ( void  )
staticinherited

static member to end keydata i/o allocations.

virtual void* MemPager::first ( size_t  size)
protectedvirtualinherited

Allocate first workspace from paged memory.

This method scans all currently allocated blocks for available space before adding new pages and hence is both slower and more efficient.

Parameters
sizesize of memory to allocate.
Returns
pointer to allocated memory.

Reimplemented in SharedMemPager.

char* MemPager::first ( char *  str)
protectedinherited

Allocate a string from the memory pager pool and copy the string into it's new memory area.

This method allocates memory by first searching for an available page, and then allocating a new page if no space is found.

Parameters
strstring to allocate and copy into paged memory pool.
Returns
copy of string from allocated memory.
bool Keydata::getBool ( const char *  key)
inherited

Get a bool value.

Parameters
symkeyword name.
Returns
true or false.
bool ost::ReconfigKeydata::getBoolean ( const char *  key)
int Keydata::getCount ( const char *  sym)
inherited

Get a count of the number of data "values" that is associated with a specific keyword.

Each value is from an accumulation of "<code>load()</code>" requests.

Parameters
symkeyword symbol name.
Returns
count of values associated with keyword.
unsigned Keydata::getCount ( void  )
inherited

Get the count of keyword indexes that are actually available so one can allocate a table to receive getIndex.

Returns
number of keywords found.
double Keydata::getDouble ( const char *  key,
double  def = 0. 
)
inherited

Get a floating value.

Parameters
symkeyword name.
defaultif not set.
Returns
value of key.
const char* Keydata::getFirst ( const char *  sym)
inherited

Get the first data value for a given keyword.

This will typically be the /etc set global default.

Parameters
symkeyword symbol name.
Returns
first set value for this symbol.
unsigned Keydata::getIndex ( char **  data,
unsigned  max 
)
inherited

Get an index array of ALL keywords that are stored by the current keydata object.

Returns
number of keywords found.
Parameters
datapointer of array to hold keyword strings.
maxnumber of entries the array can hold.
const char* ost::ReconfigKeydata::getInitial ( const char *  id)
inline

Definition at line 229 of file bayonne.h.

const char* Keydata::getLast ( const char *  sym)
inherited

Get the last (most recently set) value for a given keyword.

This is typically the value actually used.

Parameters
symkeyword symbol name.
Returns
last set value for this symbol.
const char* const* Keydata::getList ( const char *  sym)
inherited

Return a list of all values set for the given keyword returned in order.

Returns
list pointer of array holding all keyword values.
Parameters
symkeyword name to fetch.
long Keydata::getLong ( const char *  sym,
long  def = 0 
)
inherited

Get a long value, with an optional default if missing.

Parameters
symkeyword name.
defaultif not present.
Returns
long value of key.
timeout_t ost::ReconfigKeydata::getMsecTimer ( const char *  key)
int MemPager::getPages ( void  )
inlineinherited

Return the total number of pages that have been allocated for this memory pool.

Returns
number of pages allocated.

Definition at line 181 of file misc.h.

timeout_t ost::ReconfigKeydata::getSecTimer ( const char *  key)
const char* ost::StaticKeydata::getString ( const char *  id)
inlineinherited

Definition at line 164 of file bayonne.h.

const char* ost::ReconfigKeydata::getString ( const char *  key,
char *  buf,
size_t  size 
)
const char* Keydata::getString ( const char *  sym,
const char *  def = NULL 
)
inherited

Get a string value, with an optional default if missing.

Parameters
symkeyword name.
defaultif not present.
Returns
string value of key.
Keysym* Keydata::getSymbol ( const char *  sym,
bool  create 
)
protectedinherited
long ost::ReconfigKeydata::getValue ( const char *  key)
bool ost::ReconfigKeydata::isKey ( const char *  key)
void Keydata::load ( const char *  keypath)
inherited

Load additional key values into the currrent object from the specfied config source (a config file/section pair).

These values will overlay the current keywords when matches are found. This can be used typically in a derived config object class constructor to first load a /etc section, and then load a matching user specific entry from ~/. to override default system values with user specific keyword values.

Parameters
keypath(filepath/section)
void Keydata::load ( Define pairs)
inherited

Load default keywords into the current object.

This only loads keyword entries which have not already been defined to reduce memory usage. This form of Load is also commonly used in the constructor of a derived Keydata class.

Parameters
pairslist of NULL terminated default keyword/value pairs.
void Keydata::loadFile ( const char *  filepath,
const char *  keys = NULL,
const char *  pre = NULL 
)
inherited

Load additional keys into the current object using a real filename that is directly passed rather than a computed key path.

This also uses a [keys] section as passed to the object.

Parameters
filepathto load from
keyssection to parse from, or NULL to parse from head
preoptional key prefix
void Keydata::loadPrefix ( const char *  prefix,
const char *  keypath 
)
inherited

Load additional key values into the currrent object from the specfied config source (a config file/section pair).

These values will overlay the current keywords when matches are found. This can be used typically in a derived config object class constructor to first load a /etc section, and then load a matching user specific entry from ~/. to override default system values with user specific keyword values. This varient puts a prefix in front of the key name.

Parameters
prefix
keypath(filepath/section)
const char* Keydata::operator[] ( const char *  keyword)
inlineinherited

A convient notation for accessing the keydata as an associative array of keyword/value pairs through the [] operator.

Definition at line 611 of file misc.h.

void MemPager::purge ( void  )
protectedinherited

purge the current memory pool.

void ThreadLock::readLock ( void  )
inherited

Aquire a read lock for the current object.

static void ost::DynamicKeydata::reload ( void  )
staticinherited
void ost::ReconfigKeydata::setInitial ( const char *  id,
const char *  val 
)
inline

Definition at line 231 of file bayonne.h.

void Keydata::setValue ( const char *  sym,
const char *  data 
)
inherited

Set (replace) the value of a given keyword.

This new value will become the value returned from getLast(), while the prior value will still be stored and found from getList().

Parameters
symkeyword name to set.
datastring to store for the keyword.
bool ThreadLock::tryReadLock ( void  )
inherited

Attempt read lock for current object.

Returns
true on success.
bool ThreadLock::tryWriteLock ( void  )
inherited

Attempt write lock for current object.

Returns
true on success.
void Keydata::unlink ( void  )
inherited

Unlink the keydata object from the cache file stream.

This should be used if you plan to keepa Keydata object after it is loaded once all keydata objects have been loaded, otherwise the cfgFile stream will remain open. You can also use endKeydata().

void ThreadLock::unlock ( void  )
inherited

Release any held locks.

virtual void ost::DynamicKeydata::updateConfig ( Keydata keydata)
protectedvirtualinherited
bool ost::ReconfigKeydata::updatedBoolean ( const char *  id)
protected
timeout_t ost::ReconfigKeydata::updatedMsecTimer ( const char *  id)
protected
timeout_t ost::ReconfigKeydata::updatedSecTimer ( const char *  id)
protected
const char* ost::ReconfigKeydata::updatedString ( const char *  id)
protected
long ost::ReconfigKeydata::updatedValue ( const char *  id)
protected
void ThreadLock::writeLock ( void  )
inherited

Aquire a write lock for the current object.


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