00001
00002
00003
00004
00005
00006
00007 #ifndef __UNICONFROOT_H
00008 #define __UNICONFROOT_H
00009
00010
00011 #ifdef SWIG
00012 %{
00013 #include "uniconfroot.h"
00014 %}
00015 #endif // SWIG
00016
00017
00018 #include "uniconf.h"
00019 #include "uniconftree.h"
00020 #include "unimountgen.h"
00021
00022
00023 #ifndef SWIG
00024
00025
00030 class UniWatchInfo
00031 {
00032 public:
00033 void *cookie;
00034 bool recurse;
00035 UniConfCallback cb;
00036
00037 UniWatchInfo(void *_cookie, bool _recurse, UniConfCallback _cb)
00038 : cookie(_cookie), recurse(_recurse), cb(_cb) { }
00039
00041 bool recursive()
00042 { return recurse; }
00043
00045 void notify(const UniConf &cfg, const UniConfKey &key)
00046 { cb(cfg, key); }
00047
00049 bool operator== (const UniWatchInfo &other) const
00050 { return other.cookie == cookie; }
00051 };
00052 DeclareWvList(UniWatchInfo);
00053
00054
00059 class UniWatchInfoTree : public UniConfTree<UniWatchInfoTree>
00060 {
00061 public:
00062 UniWatchInfoList watches;
00063
00064 UniWatchInfoTree(UniWatchInfoTree *parent,
00065 const UniConfKey &key = UniConfKey::EMPTY)
00066 : UniConfTree<UniWatchInfoTree>(parent, key) { }
00067
00069 bool isessential()
00070 { return haschildren() || ! watches.isempty(); }
00071 };
00072
00073
00074 #endif // SWIG
00075
00076
00087 class UniConfRoot : public UniConf
00088 {
00089 friend class UniConf;
00090 friend class UniConf::Iter;
00091 friend class UniConf::RecursiveIter;
00092
00093 UniWatchInfoTree watchroot;
00094
00096 UniConfRoot(const UniConfRoot &other);
00097
00098 public:
00100 UniConfRoot();
00101
00107 UniConfRoot(WvStringParm moniker, bool refresh = true);
00108
00114 UniConfRoot(UniConfGen *gen, bool refresh = true);
00115
00117 ~UniConfRoot();
00118
00123 void add_callback(void *cookie, const UniConfKey &key,
00124 const UniConfCallback &callback, bool recurse = true);
00125
00129 void del_callback(void *cookie, const UniConfKey &key,
00130 bool recurse = true);
00131
00136 void add_setbool(const UniConfKey &key, bool *flag, bool recurse = true);
00137
00141 void del_setbool(const UniConfKey &key, bool *flag, bool recurse = true);
00142
00143 private:
00150 void check(UniWatchInfoTree *node, const UniConfKey &key, int segleft);
00151
00157 void deletioncheck(UniWatchInfoTree *node, const UniConfKey &key);
00158
00160 void prune(UniWatchInfoTree *node);
00161
00163 void gen_callback(const UniConfKey &key, WvStringParm value);
00164
00165 protected:
00166 friend class UniUnwrapGen;
00167 UniMountGen mounts;
00168
00169 public:
00171 static void setbool_callback(bool *flag, const UniConf &,
00172 const UniConfKey &)
00173 { *flag = true; }
00174
00175 };
00176
00177 #endif //__UNICONFROOT_H