Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

UniClientGen Class Reference

#include <uniclientgen.h>

Inherits UniConfGen.

Collaboration diagram for UniClientGen:

[legend]
List of all members.

Detailed Description

Communicates with a UniConfDaemon to fetch and store keys and values.

To mount, use the moniker prefix "unix:" followed by the path of the Unix domain socket used by the UniConfDaemon. Alternately, use the moniker prefix "tcp:" followed by the hostname, a colon, and the port of a machine that serves UniConfDaemon requests over TCP.

Definition at line 28 of file uniclientgen.h.

Public Member Functions

 UniClientGen (IWvStream *stream, WvStringParm dst=WvString::null)
 Creates a generator which can communicate with a daemon using the specified stream.

virtual ~UniClientGen ()
virtual bool isok ()
 Determines if the generator is usable and working properly.

virtual bool refresh ()
 Refreshes information about a key recursively.

virtual WvString get (const UniConfKey &key)
 Fetches a string value for a key from the registry.

virtual void set (const UniConfKey &key, WvStringParm value)
 Stores a string value for a key into the registry.

virtual bool haschildren (const UniConfKey &key)
 Returns true if a key has children.

virtual Iter * iterator (const UniConfKey &key)
 Returns an iterator over the children of the specified key.

void setcallback (const UniConfGenCallback &callback, void *userdata)
 Sets the callback for change notification.

void dispatch_delta (const UniConfKey &key, WvStringParm value)
 Immediately sends notification that a key has possibly changed.

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

void unhold_delta ()
 Resumes notifications when each hold_delta() has been matched.

void clear_delta ()
 Clears the list of pending notifications without sending them.

void flush_delta ()
 Flushes the list of pending notifications by sending them.

void delta (const UniConfKey &key, WvStringParm value)
 Call this when a key's value or children have possibly changed.

virtual void commit ()
 Commits any changes.

virtual bool exists (const UniConfKey &key)
 Without fetching its value, returns true if a key exists.

virtual int str2int (WvStringParm s, int defvalue) const
 Converts a string to an integer.

virtual unsigned int addRef ()
virtual unsigned int release ()

Protected Member Functions

void conncallback (WvStream &s, void *userdata)
bool do_select ()
void clientdelta (const UniConfKey &key, WvStringParm value)
void deltacb (WvStream &, void *)
void seterror (WvStringParm error)
 Raises an error condition.


Constructor & Destructor Documentation

UniClientGen::UniClientGen IWvStream stream,
WvStringParm  dst = WvString::null
 

Creates a generator which can communicate with a daemon using the specified stream.

"stream" is the raw connection

Definition at line 67 of file uniclientgen.cc.

References conncallback(), deltacb(), log, WvStream::setcallback(), WvStreamCallback, and WvStringParm.

UniClientGen::~UniClientGen  )  [virtual]
 

Definition at line 81 of file uniclientgen.cc.

References WvIStreamList::unlink(), and UniClientConn::writecmd().


Member Function Documentation

virtual unsigned int GenericComponent< IObject >::addRef  )  [inline, virtual, inherited]
 

Implements IObject.

Definition at line 67 of file wvxplc.h.

void UniConfGen::clear_delta  )  [inherited]
 

Clears the list of pending notifications without sending them.

Does not affect the hold nesting count.

Definition at line 38 of file uniconfgen.cc.

void UniClientGen::clientdelta const UniConfKey key,
WvStringParm  value
[protected]
 

Definition at line 311 of file uniclientgen.cc.

References WvStream::alarm(), and WvStringParm.

Referenced by conncallback().

virtual void UniConfGen::commit  )  [inline, virtual, inherited]
 

Commits any changes.

The default implementation does nothing.

Reimplemented in UniFilterGen, UniIniGen, UniListGen, UniMountGen, and UniMountTreeGen.

Definition at line 135 of file uniconfgen.h.

Referenced by UniFilterGen::commit(), UniMountTreeGen::unmount(), and UniMountGen::unmount().

void UniClientGen::conncallback WvStream s,
void *  userdata
[protected]
 

Definition at line 161 of file uniclientgen.cc.

References WvStream::alarm_was_ticking, clientdelta(), UniClientConn::close(), WvFastString::isnull(), log, UniClientConn::payloadbuf, UniClientConn::readcmd(), and wvtcl_getword().

Referenced by UniClientGen().

void UniConfGen::delta const UniConfKey key,
WvStringParm  value
[inherited]
 

Call this when a key's value or children have possibly changed.

If the hold nesting count is 0, the notification is sent immediately. Otherwise it is added to a pending list for later.

Definition at line 69 of file uniconfgen.cc.

References UniConfGen::dispatch_delta(), UniConfGen::hold_delta(), UniConfGen::unhold_delta(), and WvStringParm.

Referenced by deltacb(), UniFilterGen::gencallback(), UniMountGen::mountgen(), UniIniGen::refresh(), UniTempGen::set(), UniRegistryGen::set(), UniPStoreGen::set(), and UniMountGen::unmount().

void UniClientGen::deltacb WvStream ,
void * 
[protected]
 

Definition at line 317 of file uniclientgen.cc.

References UniConfGen::delta(), UniConfGen::hold_delta(), and UniConfGen::unhold_delta().

Referenced by UniClientGen().

void UniConfGen::dispatch_delta const UniConfKey key,
WvStringParm  value
[inherited]
 

Immediately sends notification that a key has possibly changed.

Takes care of the details of invoking the callback.

Note: You probably want to be using delta() instead.

Definition at line 62 of file uniconfgen.cc.

References WvStringParm.

Referenced by UniConfGen::delta(), and UniConfGen::flush_delta().

bool UniClientGen::do_select  )  [protected]
 

Definition at line 268 of file uniclientgen.cc.

References WvStream::alarm(), WvStream::callback(), UniClientConn::isok(), WvStream::select(), and UniConfGen::seterror().

Referenced by get(), haschildren(), and iterator().

bool UniConfGen::exists const UniConfKey key  )  [virtual, inherited]
 

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

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

The default implementation returns !get(key).isnull().

Reimplemented in UniFilterGen, UniListGen, UniMountGen, UniMountTreeGen, UniPStoreGen, UniRegistryGen, UniSecureGen, and UniTempGen.

Definition at line 99 of file uniconfgen.cc.

References UniConfGen::get(), and WvFastString::isnull().

Referenced by UniMountTreeGen::exists(), UniMountGen::exists(), UniFilterGen::exists(), and UniMountTreeGen::whichmount().

void UniConfGen::flush_delta  )  [inherited]
 

Flushes the list of pending notifications by sending them.

Does not affect the hold nesting count.

Definition at line 44 of file uniconfgen.cc.

References UniConfGen::dispatch_delta().

Referenced by UniConfGen::unhold_delta().

WvString UniClientGen::get const UniConfKey key  )  [virtual]
 

Fetches a string value for a key from the registry.

If the key doesn't exist, the return value is WvString::null.

Implements UniConfGen.

Definition at line 103 of file uniclientgen.cc.

References do_select(), UniConfGen::seterror(), UniClientConn::writecmd(), and wvtcl_escape().

bool UniClientGen::haschildren const UniConfKey key  )  [virtual]
 

Returns true if a key has children.

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

The default implementation uses the iterator returned by iterator() to test whether the child has any keys. Subclasses are strongly encouraged to provide a better implementation.

Reimplemented from UniConfGen.

Definition at line 134 of file uniclientgen.cc.

References do_select(), UniClientConn::writecmd(), and wvtcl_escape().

void UniConfGen::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 23 of file uniconfgen.cc.

Referenced by UniMountTreeGen::commit(), UniMountGen::commit(), UniConfGen::delta(), deltacb(), UniMountTreeGen::exists(), UniMountTreeGen::get(), UniMountTreeGen::haschildren(), UniConfGen::haschildren(), UniMountTreeGen::mountgen(), UniMountGen::mountgen(), UniMountTreeGen::refresh(), UniMountGen::refresh(), UniIniGen::refresh(), UniMountTreeGen::KeyIter::rewind(), UniTempGen::set(), set(), UniMountTreeGen::unmount(), UniMountGen::unmount(), and UniMountTreeGen::whichmount().

bool UniClientGen::isok  )  [virtual]
 

Determines if the generator is usable and working properly.

The default implementation always returns true.

Reimplemented from UniConfGen.

Definition at line 90 of file uniclientgen.cc.

References UniClientConn::isok().

UniClientGen::Iter * UniClientGen::iterator const UniConfKey key  )  [virtual]
 

Returns an iterator over the children of the specified key.

Must not return NULL; consider returning a NullIter instead.

The caller takes ownership of the returned iterator and is responsible for deleting it when finished.

Implements UniConfGen.

Definition at line 148 of file uniclientgen.cc.

References do_select(), UniClientConn::writecmd(), and wvtcl_escape().

bool UniClientGen::refresh  )  [virtual]
 

Refreshes information about a key recursively.

May discard uncommitted data.

The default implementation always returns true.

Reimplemented from UniConfGen.

Definition at line 96 of file uniclientgen.cc.

virtual unsigned int GenericComponent< IObject >::release  )  [inline, virtual, inherited]
 

Implements IObject.

Definition at line 70 of file wvxplc.h.

void UniClientGen::set const UniConfKey key,
WvStringParm  value
[virtual]
 

Stores a string value for a key into the registry.

If the value is WvString::null, the key is deleted.

Returns true on success.

Implements UniConfGen.

Definition at line 119 of file uniclientgen.cc.

References UniConfGen::hold_delta(), WvFastString::isnull(), UniConfGen::unhold_delta(), UniClientConn::writecmd(), WvStringParm, and wvtcl_escape().

void UniConfGen::setcallback const UniConfGenCallback callback,
void *  userdata
[inherited]
 

Sets the callback for change notification.

Must not be reimplemented by subclasses.

Definition at line 137 of file uniconfgen.cc.

References UniConfGenCallback.

Referenced by UniMountTreeGen::mountgen(), UniMountGen::mountgen(), UniFilterGen::setinner(), UniCacheGen::UniCacheGen(), UniConfRoot::UniConfRoot(), UniMountTreeGen::unmount(), UniMountGen::unmount(), and UniConfRoot::~UniConfRoot().

void UniConfGen::seterror WvStringParm  error  )  [inline, protected, inherited]
 

Raises an error condition.

Definition at line 57 of file uniconfgen.h.

Referenced by do_select(), and get().

int UniConfGen::str2int WvStringParm  s,
int  defvalue
const [virtual, inherited]
 

Converts a string to an integer.

If the string is null or not recognized, return defvalue.

This is here to support the common str2int(get(key)).

The default implementation recognizes the booleans 'true', 'yes', 'on' and 'enabled' as 1, and 'false', 'no', 'off' and 'disabled' as 0.

Definition at line 105 of file uniconfgen.cc.

References WvFastString::cstr(), WvFastString::isnull(), and WvStringParm.

void UniConfGen::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 29 of file uniconfgen.cc.

References UniConfGen::flush_delta().

Referenced by UniMountTreeGen::commit(), UniMountGen::commit(), UniConfGen::delta(), deltacb(), UniMountTreeGen::exists(), UniMountTreeGen::get(), UniMountTreeGen::haschildren(), UniConfGen::haschildren(), UniMountTreeGen::mountgen(), UniMountGen::mountgen(), UniMountTreeGen::refresh(), UniMountGen::refresh(), UniIniGen::refresh(), UniMountTreeGen::KeyIter::rewind(), UniTempGen::set(), set(), UniMountTreeGen::unmount(), UniMountGen::unmount(), and UniMountTreeGen::whichmount().


The documentation for this class was generated from the following files:
Generated on Sat Mar 13 15:00:07 2004 for WvStreams by doxygen 1.3.6-20040222