/usr/include/wvstreams/uniconfroot.h is in libwvstreams-dev 4.6.1-11.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | /* -*- Mode: C++ -*-
* Worldvisions Weaver Software:
* Copyright (C) 1997-2002 Net Integration Technologies, Inc.
*
* Defines the root management class for UniConf.
*/
#ifndef __UNICONFROOT_H
#define __UNICONFROOT_H
#include "uniconf.h"
#include "uniconftree.h"
#include "unimountgen.h"
/**
* @internal
* Holds information about a single watch.
*/
class UniWatchInfo
{
public:
void *cookie;
bool recurse;
UniConfCallback cb;
UniWatchInfo(void *_cookie, bool _recurse, UniConfCallback _cb)
: cookie(_cookie), recurse(_recurse), cb(_cb) { }
/** Returns watch recursion */
bool recursive()
{ return recurse; }
/** Notifies that a key has changed. */
void notify(const UniConf &cfg, const UniConfKey &key)
{ cb(cfg, key); }
/** Equality test. */
bool operator== (const UniWatchInfo &other) const
{ return other.cookie == cookie; }
};
DeclareWvList(UniWatchInfo);
/**
* @internal
* Data structure to track requested watches.
*/
class UniWatchInfoTree : public UniConfTree<UniWatchInfoTree>
{
public:
UniWatchInfoList watches;
UniWatchInfoTree(UniWatchInfoTree *parent,
const UniConfKey &key = UniConfKey::EMPTY)
: UniConfTree<UniWatchInfoTree>(parent, key) { }
/** Returns true if the node should not be pruned. */
bool isessential()
{ return haschildren() || ! watches.isempty(); }
};
/**
* 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.
*/
class UniConfRoot : public UniConf
{
friend class UniConf;
friend class UniConf::Iter;
friend class UniConf::RecursiveIter;
UniWatchInfoTree watchroot;
/** undefined. */
UniConfRoot(const UniConfRoot &other);
public:
/** Creates an empty UniConf tree with no mounted stores. */
UniConfRoot();
/**
* 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.
*/
UniConfRoot(WvStringParm moniker, 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.
*/
UniConfRoot(UniConfGen *gen, bool refresh = true);
/** Destroys the UniConf tree along with all uncommitted data. */
~UniConfRoot();
/**
* Requests notification when any of the keys covered by the
* recursive depth specification change by invoking a callback.
*/
void add_callback(void *cookie, const UniConfKey &key,
const UniConfCallback &callback, bool recurse = true);
/**
* Cancels notification requested using add_callback().
*/
void del_callback(void *cookie, const UniConfKey &key,
bool recurse = true);
/**
* Requests notification when any of the keys covered by the
* recursive depth specification change by setting a flag.
*/
void add_setbool(const UniConfKey &key, bool *flag, bool recurse = true);
/**
* Cancels notification requested using add_setbool().
*/
void del_setbool(const UniConfKey &key, bool *flag, bool recurse = true);
private:
/**
* Checks a branch of the watch tree for notification candidates.
* node - the current node
* key - the key that changed
* segleft - the number of segments left in the key (possibly negative)
*/
void check(UniWatchInfoTree *node, const UniConfKey &key, int segleft);
/**
* Recursively checks a branch of the watch tree for notification candidates.
* node - the current node
* key - the key that changed
*/
void deletioncheck(UniWatchInfoTree *node, const UniConfKey &key);
/** Prunes a branch of the watch tree. */
void prune(UniWatchInfoTree *node);
/** Callback from UniMountTreeGen (FIXME: that's a lie.) */
void gen_callback(const UniConfKey &key, WvStringParm value);
protected:
friend class UniUnwrapGen;
UniMountGen mounts;
public:
/** Internal callback for setbool style notifications. */
static void setbool_callback(bool *flag, const UniConf &,
const UniConfKey &)
{ *flag = true; }
};
#endif //__UNICONFROOT_H
|