WvStreams
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
UniConfRoot Class Reference

Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated string values. More...

#include <uniconfroot.h>

Inheritance diagram for UniConfRoot:
Inheritance graph
[legend]

Public Member Functions

 UniConfRoot ()
 Creates an empty UniConf tree with no mounted stores.
 
 UniConfRoot (WvStringParm moniker, bool refresh=true)
 Creates a new UniConf tree and mounts the given moniker at the root. More...
 
 UniConfRoot (UniConfGen *gen, bool refresh=true)
 Creates a new UniConf tree and mounts the given generator at the root. More...
 
 ~UniConfRoot ()
 Destroys the UniConf tree along with all uncommitted data.
 
void add_callback (void *cookie, const UniConfKey &key, const UniConfCallback &callback, bool recurse=true)
 Requests notification when any of the keys covered by the recursive depth specification change by invoking a callback.
 
void del_callback (void *cookie, const UniConfKey &key, bool recurse=true)
 Cancels notification requested using add_callback().
 
void add_setbool (const UniConfKey &key, bool *flag, bool recurse=true)
 Requests notification when any of the keys covered by the recursive depth specification change by setting a flag.
 
void del_setbool (const UniConfKey &key, bool *flag, bool recurse=true)
 Cancels notification requested using add_setbool().
 
UniConf root () const
 Returns a handle to the root of the tree.
 
UniConf parent () const
 Returns a handle to the parent of this node.
 
UniConfRootrootobj () const
 Returns a pointer to the UniConfRoot that manages this node. More...
 
bool isnull () const
 Returns true if the handle is invalid (NULL).
 
UniConfKey fullkey () const
 Returns the full path of this node, starting at the root.
 
UniConfKey fullkey (const UniConfKey &k) const
 Returns the full path of this node, starting at the given key. More...
 
UniConfKey fullkey (const UniConf &cfg) const
 Returns the full path of this node, starting at the given handle.
 
UniConfKey key () const
 Returns the path of this node relative to its parent.
 
const UniConf operator[] (const UniConfKey &key) const
 Returns a handle for a subtree below this key. More...
 
const UniConf u (const UniConfKey &key) const
 Return a subtree handle (see operator[]). More...
 
void prefetch (bool recursive) const
 See UniConfGen::prefetch().
 
WvString getme (WvStringParm defvalue=WvString::null) const
 Fetches the string value for this key from the registry. More...
 
WvString operator* () const
 A different way to say cfg.getme(): use *cfg instead.
 
WvStringStar operator-> () const
 A different way to say cfg.getme().num(): use cfg->num() instead.
 
WvString xget (WvStringParm key, WvStringParm defvalue=WvString::null) const
 A different way to say cfg[x].getme(y).
 
int getmeint (int defvalue=0) const
 Fetches the integer value for this key from the registry. More...
 
int xgetint (WvStringParm key, int defvalue=0) const
 A different way to say cfg[x].getmeint(y).
 
bool exists () const
 Without fetching its value, returns true if this key exists. More...
 
void setme (WvStringParm value) const
 Stores a string value for this key into the registry. More...
 
void setme (WVSTRING_FORMAT_DECL) const
 Stores a string value for this key into the registry.
 
void xset (WvStringParm key, WvStringParm value) const
 A different way to say cfg[x].setme(y).
 
void setmeint (int value) const
 Stores an integer value for this key into the registry.
 
void xsetint (WvStringParm key, int value) const
 A different way to say cfg[x].setme(y).
 
void move (const UniConf &dst) const
 Equivalent to "mv" in a standard unix filesystem. More...
 
void remove () const
 Removes this key and all of its children from the registry.
 
void copy (const UniConf &dst, bool force) const
 Equivalent to "cp -r" in a standard unix filesystem. More...
 
bool refresh () const
 Refreshes information about this key recursively. More...
 
void commit () const
 Commits information about this key recursively.
 
IUniConfGenmount (WvStringParm moniker, bool refresh=true) const
 Mounts a generator at this key using a moniker. More...
 
IUniConfGenmountgen (IUniConfGen *gen, bool refresh=true) const
 Mounts a generator at this key. More...
 
void unmount (IUniConfGen *gen, bool commit) const
 Unmounts the generator providing this key and destroys it.
 
bool ismountpoint () const
 Determines if any generators are mounted at this key.
 
bool isok () const
 Returns true if the generator at this key isok().
 
IUniConfGenwhichmount (UniConfKey *mountpoint=NULL) const
 Finds the generator that owns this key. More...
 
void add_callback (void *cookie, const UniConfCallback &callback, bool recurse=true) const
 Requests notification when any of the keys covered by the recursive depth specification change by invoking a callback. More...
 
void del_callback (void *cookie, bool recurse=true) const
 Cancels notification requested using add_callback().
 
void add_setbool (bool *flag, bool recurse=true) const
 Requests notification when any of the keys covered by the recursive depth specification change by setting a flag.
 
void del_setbool (bool *flag, bool recurse=true) const
 Cancels notification requested using add_setbool().
 
void hold_delta ()
 Pauses notifications until matched with a call to unhold_delta(). More...
 
void unhold_delta ()
 Resumes notifications when each hold_delta() has been matched. More...
 
void clear_delta ()
 Clears the list of pending notifications without sending them. More...
 
void flush_delta ()
 Flushes the list of pending notifications by sending them. More...
 
void dump (WvStream &stream, bool everything=false) const
 Prints the entire contents of this subtree to a stream. More...
 
bool haschildren () const
 Returns true if this key has children. More...
 
 DeclareWvList (Iter)
 

Static Public Member Functions

static void setbool_callback (bool *flag, const UniConf &, const UniConfKey &)
 Internal callback for setbool style notifications.
 

Protected Attributes

UniMountGen mounts
 
UniConfRootxroot
 
UniConfKey xfullkey
 

Friends

class UniConf
 
class UniConf::Iter
 
class UniConf::RecursiveIter
 
class UniUnwrapGen
 

Detailed Description

Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated string values.

Any number of data containers may be mounted into the tree at any number of mount points to provide a backing store from which registry keys and values are fetched and into which they are stored. Multiple data containers may be mounted at the same location using standard unix semantics.

Definition at line 73 of file uniconfroot.h.

Constructor & Destructor Documentation

◆ UniConfRoot() [1/2]

UniConfRoot::UniConfRoot ( WvStringParm  moniker,
bool  refresh = true 
)

Creates a new UniConf tree and mounts the given moniker at the root.

Since most people only want to mount one generator, this should save a line of code here and there.

Definition at line 23 of file uniconfroot.cc.

References UniConfGen::add_callback(), UniMountGen::mount(), and UniConf::refresh().

◆ UniConfRoot() [2/2]

UniConfRoot::UniConfRoot ( UniConfGen gen,
bool  refresh = true 
)

Creates a new UniConf tree and mounts the given generator at the root.

Since most people only want to mount one generator, this should save a line of code here and there.

Definition at line 33 of file uniconfroot.cc.

References UniConfGen::add_callback(), UniMountGen::mountgen(), and UniConf::refresh().

Member Function Documentation

◆ rootobj()

UniConfRoot* UniConf::rootobj ( ) const
inlineinherited

Returns a pointer to the UniConfRoot that manages this node.

This may be NULL, to signal an invalid handle.

Definition at line 91 of file uniconf.h.

Referenced by UniConf::Iter::Iter(), UniConf::RecursiveIter::RecursiveIter(), and UniUnwrapGen::setv().

◆ fullkey()

UniConfKey UniConf::fullkey ( const UniConfKey k) const
inherited

Returns the full path of this node, starting at the given key.

Assumes that k is an ancestor of fullkey().

Definition at line 44 of file uniconf.cc.

References UniConfKey::subkey().

◆ operator[]()

const UniConf UniConf::operator[] ( const UniConfKey key) const
inlineinherited

Returns a handle for a subtree below this key.

'key' is the path of the subtree to be appended to the full path of this handle to obtain the full path of the new handle.

Definition at line 119 of file uniconf.h.

References UniConf::key(), and UniConf::UniConf().

◆ u()

const UniConf UniConf::u ( const UniConfKey key) const
inlineinherited

Return a subtree handle (see operator[]).

Mainly to support bindings for languages that can't handle methods named [].

Definition at line 126 of file uniconf.h.

References UniConf::key().

◆ getme()

WvString UniConf::getme ( WvStringParm  defvalue = WvString::null) const
inherited

Fetches the string value for this key from the registry.

If the key is not found, returns 'defvalue' instead.

Definition at line 68 of file uniconf.cc.

References WvFastString::isnull().

Referenced by UniConf::copy(), UniUnwrapGen::get(), UniConf::getmeint(), UniConf::operator*(), and UniConf::operator->().

◆ getmeint()

int UniConf::getmeint ( int  defvalue = 0) const
inherited

Fetches the integer value for this key from the registry.

If the key is not found, returns 'defvalue' instead. (This is also used to fetch booleans - 'true', 'yes', 'on' and 'enabled' are recognized as 1, 'false', 'no', 'off' and 'disabled' as 0. Note that a nonexistant key is false by default.)

Definition at line 77 of file uniconf.cc.

References UniConf::getme().

◆ exists()

bool UniConf::exists ( ) const
inherited

Without fetching its value, returns true if this key exists.

This is provided because it is often more efficient to test existance than to actually retrieve the value.

Definition at line 50 of file uniconf.cc.

Referenced by UniUnwrapGen::exists().

◆ setme()

void UniConf::setme ( WvStringParm  value) const
inherited

Stores a string value for this key into the registry.

If the value is WvString::null, deletes the key and all of its children.

Definition at line 83 of file uniconf.cc.

Referenced by UniConf::copy(), UniConf::remove(), UniUnwrapGen::set(), UniConf::setme(), and UniConf::setmeint().

◆ move()

void UniConf::move ( const UniConf dst) const
inherited

Equivalent to "mv" in a standard unix filesystem.

This recursively moves a given key and any subkeys to a new point. If the new point exists then the key will be left as a subkey at the new point. Otherwise, the key will also be renamed to the new point (as when using mv).

Don't try to do dumb stuff like making dst a subkey of this one, or vice versa, because we won't try to save you.

Unlike unix mv(), this is not currently atomic. It's more like cp-then-rm.

Definition at line 95 of file uniconf.cc.

References UniConf::copy(), and UniConf::remove().

◆ copy()

void UniConf::copy ( const UniConf dst,
bool  force 
) const
inherited

Equivalent to "cp -r" in a standard unix filesystem.

This recursively copies a given key to a new location. Any keys that already exist at that location will not be overridden unless force is true.

Don't try to do dumb stuff like making dst a subkey of this one, or vice versa, because we won't try to save you.

Definition at line 103 of file uniconf.cc.

References UniConf::getme(), WvFastString::isnull(), and UniConf::setme().

Referenced by UniConf::move().

◆ refresh()

bool UniConf::refresh ( ) const
inherited

Refreshes information about this key recursively.

May discard uncommitted data. Returns true on success.

Definition at line 119 of file uniconf.cc.

Referenced by UniConf::mount(), UniConf::mountgen(), UniUnwrapGen::refresh(), and UniConfRoot().

◆ mount()

IUniConfGen * UniConf::mount ( WvStringParm  moniker,
bool  refresh = true 
) const
inherited

Mounts a generator at this key using a moniker.

If 'refresh' is true, automatically refresh()es the generator after mounting.

Returns the mounted generator, or NULL on failure.

Definition at line 131 of file uniconf.cc.

References UniConf::refresh().

◆ mountgen()

IUniConfGen * UniConf::mountgen ( IUniConfGen gen,
bool  refresh = true 
) const
inherited

Mounts a generator at this key.

Takes ownership of the supplied generator instance.

If 'refresh' is true, automatically refresh()es the generator after mounting.

Returns the mounted generator, or NULL on failure.

Definition at line 137 of file uniconf.cc.

References UniConf::refresh().

◆ whichmount()

IUniConfGen * UniConf::whichmount ( UniConfKey mountpoint = NULL) const
inherited

Finds the generator that owns this key.

If the key exists, returns the generator that provides its contents. Otherwise returns the generator that would be updated if a value were set.

If non-NULL, 'mountpoint' is set to the actual key where the generator is mounted.

Definition at line 155 of file uniconf.cc.

Referenced by UniUnwrapGen::isok(), and UniConf::isok().

◆ add_callback()

void UniConf::add_callback ( void *  cookie,
const UniConfCallback &  callback,
bool  recurse = true 
) const
inherited

Requests notification when any of the keys covered by the recursive depth specification change by invoking a callback.

As a programmer, you probably DO NOT want to use this. Use UniWatchList.add() instead. Otherwise, make sure you call del_callback at the appropriate time.

Definition at line 168 of file uniconf.cc.

◆ hold_delta()

void UniConf::hold_delta ( )
inherited

Pauses notifications until matched with a call to unhold_delta().

While paused, notification events are placed into a pending list. Redundant notifications may be discarded.

Use this to safeguard non-reentrant code.

Definition at line 193 of file uniconf.cc.

◆ unhold_delta()

void UniConf::unhold_delta ( )
inherited

Resumes notifications when each hold_delta() has been matched.

On resumption, dispatches all pending notifications except those that were destined to watches that were removed.

Use this to safeguard non-reentrant code.

Definition at line 199 of file uniconf.cc.

◆ clear_delta()

void UniConf::clear_delta ( )
inherited

Clears the list of pending notifications without sending them.

Does not affect the hold nesting count.

Definition at line 205 of file uniconf.cc.

◆ flush_delta()

void UniConf::flush_delta ( )
inherited

Flushes the list of pending notifications by sending them.

Does not affect the hold nesting count.

Definition at line 211 of file uniconf.cc.

◆ dump()

void UniConf::dump ( WvStream stream,
bool  everything = false 
) const
inherited

Prints the entire contents of this subtree to a stream.

If 'everything' is true, also prints empty values.

Definition at line 217 of file uniconf.cc.

◆ haschildren()

bool UniConf::haschildren ( ) const
inherited

Returns true if this key has children.

This is provided because it is often more efficient to test existance than to actually retrieve the keys.

Definition at line 56 of file uniconf.cc.

Referenced by UniUnwrapGen::haschildren().


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