Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

unimounttreegen.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  * 
00005  * Defines a UniConfGen that manages a tree of UniConfGen instances.
00006  */
00007 #ifndef __UNIMOUNTTREEGEN_H
00008 #define __UNIMOUNTTREEGEN_H
00009 
00010 #include "uniconfgen.h"
00011 #include "uniconftree.h"
00012 #include "wvstringtable.h"
00013 
00018 class UniMountTree : public UniConfTree<UniMountTree>
00019 {
00020 public:
00021     UniConfGenList generators;
00022 
00023     UniMountTree(UniMountTree *parent, const UniConfKey &key);
00024     ~UniMountTree();
00025 
00027     bool isessential()
00028         { return haschildren() || ! generators.isempty(); }
00029 
00036     UniMountTree *findnearest(const UniConfKey &key, int &split);
00037 
00039     UniMountTree *findormake(const UniConfKey &key);
00040    
00041     // an iterator over nodes that have information about a key
00042     class MountIter;
00043     // an iterator over generators about a key
00044     class GenIter;
00045 };
00046 
00047 
00053 class UniMountTree::MountIter
00054 {
00055     int bestsplit;
00056     UniMountTree *bestnode;
00057 
00058     int xsplit;
00059     UniMountTree *xnode;
00060     UniConfKey xkey;
00061 
00062 public:
00063     MountIter(UniMountTree &root, const UniConfKey &key);
00064     
00065     void rewind();
00066     bool next();
00067     
00068     int split() const
00069         { return xsplit; }
00070     UniConfKey key() const
00071         { return xkey; }
00072     UniConfKey head() const
00073         { return xkey.first(xsplit); }
00074     UniConfKey tail() const
00075         { return xkey.removefirst(xsplit); }
00076     UniMountTree *node() const
00077         { return xnode; }
00078     UniMountTree *ptr() const
00079         { return node(); }
00080     WvIterStuff(UniMountTree);
00081 };
00082 
00083 
00093 class UniMountTree::GenIter : private UniMountTree::MountIter
00094 {
00095     UniConfGenList::Iter *genit; 
00097 public:
00098     GenIter(UniMountTree &root, const UniConfKey &key);
00099     ~GenIter();
00100 
00101     typedef UniMountTree::MountIter ParentClass;
00102     using ParentClass::split;
00103     using ParentClass::key;
00104     using ParentClass::head;
00105     using ParentClass::tail;
00106     using ParentClass::node;
00107 
00108     void rewind();
00109     bool next();
00110 
00111     IUniConfGen *ptr() const
00112         { return genit ? genit->ptr() : NULL; }
00113     WvIterStuff(IUniConfGen);
00114 };
00115 
00116 
00118 class UniMountTreeGen : public UniConfGen
00119 {
00120     class KeyIter;
00121     friend class KeyIter;
00122     
00123     UniMountTree *mounts;
00124 
00126     UniMountTreeGen(const UniMountTreeGen &other);
00127 
00128 public:
00130     UniMountTreeGen();
00131 
00133     ~UniMountTreeGen();
00134     
00140     virtual IUniConfGen *mount(const UniConfKey &key, WvStringParm moniker,
00141         bool refresh);
00142     
00152     virtual IUniConfGen *mountgen(const UniConfKey &key, IUniConfGen *gen,
00153         bool refresh);
00154 
00162     virtual void unmount(const UniConfKey &key, IUniConfGen *gen, bool commit);
00163     
00176     virtual IUniConfGen *whichmount(const UniConfKey &key,
00177                                     UniConfKey *mountpoint);
00178 
00180     virtual bool ismountpoint(const UniConfKey &key);
00181     
00182     /***** Overridden members *****/
00183     
00184     virtual bool exists(const UniConfKey &key);
00185     virtual bool haschildren(const UniConfKey &key);
00186     virtual WvString get(const UniConfKey &key);
00187     virtual void set(const UniConfKey &key, WvStringParm value);
00188     virtual bool refresh();
00189     virtual void commit();
00190     virtual Iter *iterator(const UniConfKey &key);
00191 
00192 private:
00198     void prune(UniMountTree *node);
00199 
00201     void gencallback(const UniConfKey &key, WvStringParm value, void *userdata);
00202 };
00203 
00204 
00205 #endif //__UNIMOUNTTREEGEN_H

Generated on Sun Jul 10 14:05:51 2005 for WvStreams by  doxygen 1.4.0