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

unimountgen.h

Go to the documentation of this file.
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 __UNIMOUNTGEN_H
00008 #define __UNIMOUNTGEN_H
00009 
00010 #include "uniconfgen.h"
00011 #include "wvcallback.h"
00012 #include "wvmoniker.h"
00013 #include "wvstringlist.h"
00014 
00015 
00016 /** The UniMountTree implementation realized as a UniConfGen. */
00017 class UniMountGen : public UniConfGen
00018 {
00019 protected:
00020 
00021     // Class to hold the generator with its mountpoint    
00022     class UniGenMount
00023     {
00024     public:
00025         UniGenMount(UniConfGen *gen, const UniConfKey &key)
00026             : gen(gen), key(key) 
00027             { }
00028 
00029         ~UniGenMount()
00030             { delete gen; }
00031 
00032         UniConfGen *gen;
00033         UniConfKey key;
00034     };
00035 
00036     typedef class WvList<UniGenMount> MountList;
00037     MountList mounts;
00038 
00039 public:
00040     /** Creates an empty UniConf tree with no mounted stores. */
00041     UniMountGen() 
00042         { }
00043 
00044     /** undefined. */
00045     UniMountGen(const UniMountGen &other);
00046 
00047     /** Destroys the UniConf tree along with all uncommitted data. */
00048     virtual ~UniMountGen()
00049         { }
00050     
00051     /**
00052      * Mounts a generator at a key using a moniker.
00053      
00054      * Returns the generator instance pointer, or NULL on failure.
00055      */
00056     virtual UniConfGen *mount(const UniConfKey &key, WvStringParm moniker,
00057         bool refresh);
00058     
00059     /**
00060      * Mounts a generator at a key.
00061      * Takes ownership of the supplied generator instance.
00062      * 
00063      * "key" is the key
00064      * "gen" is the generator instance
00065      * "refresh" is if true, refreshes the generator after mount
00066      * Returns: the generator instance pointer, or NULL on failure
00067      */
00068     virtual UniConfGen *mountgen(const UniConfKey &key, UniConfGen *gen,
00069         bool refresh);
00070 
00071     /**
00072      * Unmounts the generator at a key and destroys it.
00073      *
00074      * "gen" is the generator instance
00075      * "commit" is if true, commits the generator before unmount
00076      */
00077     virtual void unmount(UniConfGen *gen, bool commit);
00078     
00079     /**
00080      * Finds the generator that owns a key.
00081      * 
00082      * If the key exists, returns the generator that provides its
00083      * contents.  Otherwise returns the generator that would be
00084      * updated if a value were set.
00085      * 
00086      * "key" is the key
00087      * "mountpoint" is if not NULL, replaced with the mountpoint
00088      *        path on success
00089      * Returns: the handle, or a null handle if none
00090      */
00091     virtual UniConfGen *whichmount(const UniConfKey &key,
00092                                    UniConfKey *mountpoint);
00093 
00094     /** Determines if a key is a mountpoint. */
00095     virtual bool ismountpoint(const UniConfKey &key);
00096     
00097     /***** Overridden members *****/
00098     
00099     virtual bool exists(const UniConfKey &key);
00100     virtual bool haschildren(const UniConfKey &key);
00101     virtual WvString get(const UniConfKey &key);
00102     virtual void set(const UniConfKey &key, WvStringParm value);
00103     virtual bool refresh();
00104     virtual void commit();
00105     virtual Iter *iterator(const UniConfKey &key);
00106 
00107 private:
00108     /** Find the active generator for a given key. */
00109     UniGenMount *findmount(const UniConfKey &key);
00110 
00111     // Trim the key so it matches the generator starting point
00112     UniConfKey trimkey(const UniConfKey &foundkey, const UniConfKey &key)
00113         { return key.removefirst(foundkey.numsegments()); }
00114 
00115     /** Called by generators when a key changes. */
00116     void gencallback(const UniConfKey &key, WvStringParm value,
00117                      void *userdata);
00118 
00119     void makemount(const UniConfKey &key);
00120 };
00121 
00122 #endif //__UNIMOUNTGEN_H

Generated on Wed Dec 15 15:08:10 2004 for WvStreams by  doxygen 1.3.9.1