2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * Defines a UniConfGen that manages a tree of UniConfGen instances.
7 #ifndef __UNIMOUNTGEN_H
8 #define __UNIMOUNTGEN_H
10 #include "uniconfgen.h"
11 #include "wvmoniker.h"
12 #include "wvstringlist.h"
16 /** The UniMountTree implementation realized as a UniConfGen. */
17 class UniMountGen
: public UniConfGen
21 // Class to hold the generator with its mountpoint
25 UniGenMount(IUniConfGen
*gen
, const UniConfKey
&key
)
29 xplc_ptr
<IUniConfGen
> gen
;
33 typedef class WvList
<UniGenMount
> MountList
;
37 UniMountGen(const UniMountGen
&other
);
40 /** Creates an empty UniConf tree with no mounted stores. */
43 /** Destroys the UniConf tree along with all uncommitted data. */
44 virtual ~UniMountGen();
49 * Mounts a generator at a key using a moniker.
51 * Returns the generator instance pointer, or NULL on failure.
53 virtual IUniConfGen
*mount(const UniConfKey
&key
,
58 * Mounts a generator at a key.
59 * Takes ownership of the supplied generator instance.
62 * "gen" is the generator instance
63 * "refresh" is if true, refreshes the generator after mount
64 * Returns: the generator instance pointer, or NULL on failure
66 virtual IUniConfGen
*mountgen(const UniConfKey
&key
,
71 * Unmounts the generator at a key and releases it.
73 * "gen" is the generator instance
74 * "commit" is if true, commits the generator before unmount
76 virtual void unmount(IUniConfGen
*gen
, bool commit
);
79 * Finds the generator that owns a key.
81 * If the key exists, returns the generator that provides its
82 * contents. Otherwise returns the generator that would be
83 * updated if a value were set.
86 * "mountpoint" is if not NULL, replaced with the mountpoint
88 * Returns: the handle, or a null handle if none
90 virtual IUniConfGen
*whichmount(const UniConfKey
&key
,
91 UniConfKey
*mountpoint
);
93 /** Determines if a key is a mountpoint. */
94 virtual bool ismountpoint(const UniConfKey
&key
);
96 /***** Overridden members *****/
98 virtual bool exists(const UniConfKey
&key
);
99 virtual bool haschildren(const UniConfKey
&key
);
100 virtual WvString
get(const UniConfKey
&key
);
101 virtual void set(const UniConfKey
&key
, WvStringParm value
);
102 virtual void setv(const UniConfPairList
&pairs
);
103 virtual void commit();
104 virtual bool refresh();
105 virtual void flush_buffers() { }
106 virtual Iter
*iterator(const UniConfKey
&key
);
107 virtual Iter
*recursiveiterator(const UniConfKey
&key
);
110 /** Find the active generator for a given key. */
111 UniGenMount
*findmount(const UniConfKey
&key
);
112 /** Find a unique active generator a given key, will return NULL if
113 * there are other generators beneath that key. */
114 UniGenMount
*findmountunder(const UniConfKey
&key
);
116 // Trim the key so it matches the generator starting point
117 UniConfKey
trimkey(const UniConfKey
&foundkey
, const UniConfKey
&key
)
118 { return key
.removefirst(foundkey
.numsegments()); }
120 /** Called by generators when a key changes. */
121 void gencallback(const UniConfKey
&base
, const UniConfKey
&key
,
124 void makemount(const UniConfKey
&key
);
126 /** Return true if the given key has a subkey
127 * if you used findmount first, give the result as a parameter to
128 * improve efficiency*/
129 bool has_subkey(const UniConfKey
&key
, UniGenMount
*found
= NULL
);
131 struct UniGenMountPairs
;
132 DeclareWvDict(UniGenMountPairs
, WvFastString
, key
);
136 #endif //__UNIMOUNTGEN_H