8#include "uniconfroot.h"
9#include "wvlinkerhack.h"
11WV_LINK_TO(UniGenHack);
18 mounts.add_callback(
this, wv::bind(&UniConfRoot::gen_callback,
this,
27 mounts.mount(
"/", moniker,
refresh);
28 mounts.add_callback(
this, wv::bind(&UniConfRoot::gen_callback,
this,
37 mounts.mountgen(
"/", gen,
refresh);
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));
83 mounts.del_callback(
this);
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)
158 UniWatchInfoTree::Iter i(*node);
159 for (i.rewind(); i.next(); )
161 UniWatchInfoTree *w = i.ptr();
162 UniConfKey subkey(
key, w->
key());
166 deletioncheck(w, subkey);
173 while (node != & watchroot && ! node->
isessential())
175 UniWatchInfoTree *next = node->
parent();
182void UniConfRoot::gen_callback(
const UniConfKey &key, WvStringParm value)
185 UniWatchInfoTree *node = & watchroot;
186 int segs =
key.numsegments();
189 check(node,
key, segs);
192 for (
int s = 0; s < segs; )
198 check(node,
key, segs - s);
203 deletioncheck(node,
key);
A default implementation of IUniConfGen, providing various handy features that save trouble when impl...
An iterator over the segments of a key.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
WvString printable() const
Returns the canonical string representation of the path.
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
UniConfKey last(int n=1) const
Returns the path formed by the n last segments of this path.
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.
static void setbool_callback(bool *flag, const UniConf &, const UniConfKey &)
Internal callback for setbool style notifications.
void del_callback(void *cookie, const UniConfKey &key, bool recurse=true)
Cancels notification requested using add_callback().
void del_setbool(const UniConfKey &key, bool *flag, bool recurse=true)
Cancels notification requested using add_setbool().
~UniConfRoot()
Destroys the UniConf tree along with all uncommitted data.
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...
UniConfKey fullkey(const Sub *ancestor=NULL) const
Returns full path of this node relative to an ancestor.
Sub * parent() const
Returns a pointer to the parent node, or NULL if there is none.
Sub * find(const UniConfKey &key) const
Finds the sub-node with the specified key.
Sub * findchild(const UniConfKey &key) const
Finds the direct child node with the specified key.
UniConfKey key() const
Returns the path of this node relative to its parent.
UniConf()
Creates a NULL UniConf handle, useful for reporting errors.
bool refresh() const
Refreshes information about this key recursively.
void unhold_delta()
Resumes notifications when each hold_delta() has been matched.
void hold_delta()
Pauses notifications until matched with a call to unhold_delta().
const UniConfKey & key() const
Returns the key field.
bool haschildren() const
Returns true if the node has children.
bool isessential()
Returns true if the node should not be pruned.
bool isnull() const
returns true if this string is null
const char * cstr() const
return a (const char *) for this string.