00001
00002
00003
00004
00005
00006
00007 #ifndef __UNICONFROOT_H
00008 #define __UNICONFROOT_H
00009
00010 #include "uniconf.h"
00011 #include "uniconftree.h"
00012 #include "unimountgen.h"
00013
00014
00019 class UniWatchInfo
00020 {
00021 public:
00022 void *cookie;
00023 bool recurse;
00024 UniConfCallback cb;
00025
00026 UniWatchInfo(void *_cookie, bool _recurse, UniConfCallback _cb)
00027 : cookie(_cookie), recurse(_recurse), cb(_cb) { }
00028
00030 bool recursive()
00031 { return recurse; }
00032
00034 void notify(const UniConf &cfg, const UniConfKey &key)
00035 { cb(cfg, key); }
00036
00038 bool operator== (const UniWatchInfo &other) const
00039 { return other.cookie == cookie; }
00040 };
00041 DeclareWvList(UniWatchInfo);
00042
00043
00048 class UniWatchInfoTree : public UniConfTree<UniWatchInfoTree>
00049 {
00050 public:
00051 UniWatchInfoList watches;
00052
00053 UniWatchInfoTree(UniWatchInfoTree *parent,
00054 const UniConfKey &key = UniConfKey::EMPTY)
00055 : UniConfTree<UniWatchInfoTree>(parent, key) { }
00056
00058 bool isessential()
00059 { return haschildren() || ! watches.isempty(); }
00060 };
00061
00062
00073 class UniConfRoot : public UniConf
00074 {
00075 friend class UniConf;
00076 friend class UniConf::Iter;
00077 friend class UniConf::RecursiveIter;
00078
00079 UniWatchInfoTree watchroot;
00080
00082 UniConfRoot(const UniConfRoot &other);
00083
00084 public:
00086 UniConfRoot();
00087
00093 UniConfRoot(WvStringParm moniker, bool refresh = true);
00094
00100 UniConfRoot(UniConfGen *gen, bool refresh = true);
00101
00103 ~UniConfRoot();
00104
00109 void add_callback(void *cookie, const UniConfKey &key,
00110 const UniConfCallback &callback, bool recurse = true);
00111
00115 void del_callback(void *cookie, const UniConfKey &key,
00116 bool recurse = true);
00117
00122 void add_setbool(const UniConfKey &key, bool *flag, bool recurse = true);
00123
00127 void del_setbool(const UniConfKey &key, bool *flag, bool recurse = true);
00128
00129 private:
00136 void check(UniWatchInfoTree *node, const UniConfKey &key, int segleft);
00137
00143 void deletioncheck(UniWatchInfoTree *node, const UniConfKey &key);
00144
00146 void prune(UniWatchInfoTree *node);
00147
00149 void gen_callback(const UniConfKey &key, WvStringParm value);
00150
00151 protected:
00152 friend class UniUnwrapGen;
00153 UniMountGen mounts;
00154
00155 public:
00157 static void setbool_callback(bool *flag, const UniConf &,
00158 const UniConfKey &)
00159 { *flag = true; }
00160
00161 };
00162
00163 #endif //__UNICONFROOT_H