8 #include "uniconfroot.h"
9 #include "wvlinkerhack.h"
11 WV_LINK_TO(UniGenHack);
18 mounts.
add_callback(
this, wv::bind(&UniConfRoot::gen_callback,
this,
28 mounts.
add_callback(
this, wv::bind(&UniConfRoot::gen_callback,
this,
38 mounts.
add_callback(
this, wv::bind(&UniConfRoot::gen_callback,
this,
49 for (i.rewind(); i.next(); )
57 if (!w->watches.isempty())
61 fprintf(stderr,
"Remaining watch: '%s' (%zd)\n",
81 assert(!watchout(&watchroot));
88 const UniConfCallback &callback,
bool recurse)
95 for (i.rewind(); i.next(); )
102 node->watches.append(w,
true);
112 UniWatchInfoList::Iter i(node->watches);
113 for (i.rewind(); i.next(); )
116 if (i->cookie == cookie && i->recurse == recurse)
145 UniWatchInfoList::Iter i(node->watches);
146 for (i.rewind(); i.next(); )
148 if (!i->recursive() && segleft > 0)
159 for (i.rewind(); i.next(); )
166 deletioncheck(w, subkey);
173 while (node != & watchroot && ! node->
isessential())
182 void UniConfRoot::gen_callback(
const UniConfKey &key, WvStringParm value)
189 check(node,
key, segs);
192 for (
int s = 0; s < segs; )
198 check(node,
key, segs - s);
203 deletioncheck(node,
key);
bool refresh() const
Refreshes information about this key recursively.
virtual IUniConfGen * mount(const UniConfKey &key, WvStringParm moniker, bool refresh)
Mounts a generator at a key using a moniker.
void del_setbool(const UniConfKey &key, bool *flag, bool recurse=true)
Cancels notification requested using add_setbool().
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 inv...
UniConfRoot()
Creates an empty UniConf tree with no mounted stores.
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
UniConf instances function as handles to subtrees of a UniConf tree and expose a high-level interface...
WvString printable() const
Returns the canonical string representation of the path.
Sub * findchild(const UniConfKey &key) const
Finds the direct child node with the specified key.
static void setbool_callback(bool *flag, const UniConf &, const UniConfKey &)
Internal callback for setbool style notifications.
const UniConfKey & key() const
Returns the key field.
An iterator over the segments of a key.
const char * cstr() const
return a (const char *) for this string.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
virtual IUniConfGen * mountgen(const UniConfKey &key, IUniConfGen *gen, bool refresh)
Mounts a generator at a key.
Sub * parent() const
Returns a pointer to the parent node, or NULL if there is none.
A default implementation of IUniConfGen, providing various handy features that save trouble when impl...
bool isessential()
Returns true if the node should not be pruned.
UniConfKey fullkey(const Sub *ancestor=NULL) const
Returns full path of this node relative to an ancestor.
void del_callback(void *cookie, const UniConfKey &key, bool recurse=true)
Cancels notification requested using add_callback().
UniConfKey segment(int n) const
Returns the specified segment of the path.
bool haschildren() const
Returns true if the node has children.
void hold_delta()
Pauses notifications until matched with a call to unhold_delta().
Sub * find(const UniConfKey &key) const
Finds the sub-node with the specified key.
~UniConfRoot()
Destroys the UniConf tree along with all uncommitted data.
UniConfKey last(int n=1) const
Returns the path formed by the n last segments of this path.
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 set...
int numsegments() const
Returns the number of segments in this path.
virtual void add_callback(void *cookie, const UniConfGenCallback &callback)
Adds a callback for change notification.
UniConfKey key() const
Returns the path of this node relative to its parent.
virtual void del_callback(void *cookie)
Removes a callback for change notification.
void unhold_delta()
Resumes notifications when each hold_delta() has been matched.