WvStreams
unimountgen.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * Defines a UniConfGen that manages a tree of UniConfGen instances.
6 */
7#ifndef __UNIMOUNTGEN_H
8#define __UNIMOUNTGEN_H
9
10#include "uniconfgen.h"
11#include "wvmoniker.h"
12#include "wvstringlist.h"
13#include "wvtr1.h"
14
15
17class UniMountGen : public UniConfGen
18{
19protected:
20
21 // Class to hold the generator with its mountpoint
23 {
24 public:
25 UniGenMount(IUniConfGen *gen, const UniConfKey &key)
26 : gen(gen), key(key)
27 { }
28
30 UniConfKey key;
31 };
32
33 typedef class WvList<UniGenMount> MountList;
34 MountList mounts;
35
37 UniMountGen(const UniMountGen &other);
38
39public:
42
44 virtual ~UniMountGen();
45
46 void zap();
47
53 virtual IUniConfGen *mount(const UniConfKey &key,
54 WvStringParm moniker,
55 bool refresh);
56
66 virtual IUniConfGen *mountgen(const UniConfKey &key,
67 IUniConfGen *gen,
68 bool refresh);
69
76 virtual void unmount(IUniConfGen *gen, bool commit);
77
90 virtual IUniConfGen *whichmount(const UniConfKey &key,
91 UniConfKey *mountpoint);
92
94 virtual bool ismountpoint(const UniConfKey &key);
95
96 /***** Overridden members *****/
97
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);
108
109private:
111 UniGenMount *findmount(const UniConfKey &key);
114 UniGenMount *findmountunder(const UniConfKey &key);
115
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()); }
119
121 void gencallback(const UniConfKey &base, const UniConfKey &key,
122 WvStringParm value);
123
124 void makemount(const UniConfKey &key);
125
129 bool has_subkey(const UniConfKey &key, UniGenMount *found = NULL);
130
131 struct UniGenMountPairs;
132 DeclareWvDict(UniGenMountPairs, WvFastString, key);
133
134};
135
136#endif //__UNIMOUNTGEN_H
An abstract data container that backs a UniConf tree.
Definition uniconfgen.h:40
A default implementation of IUniConfGen, providing various handy features that save trouble when impl...
Definition uniconfgen.h:200
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
Definition uniconfkey.h:39
UniConfKey removefirst(int n=1) const
Returns the path formed by removing the first n segments of this path.
Definition uniconfkey.h:335
int numsegments() const
Returns the number of segments in this path.
Definition uniconfkey.h:287
The UniMountTree implementation realized as a UniConfGen.
Definition unimountgen.h:18
virtual void commit()
Commits any changes.
virtual IUniConfGen * whichmount(const UniConfKey &key, UniConfKey *mountpoint)
Finds the generator that owns a key.
virtual IUniConfGen * mountgen(const UniConfKey &key, IUniConfGen *gen, bool refresh)
Mounts a generator at a key.
virtual Iter * recursiveiterator(const UniConfKey &key)
Like iterator(), but the returned iterator is recursive, that is, it will return children of the imme...
virtual bool ismountpoint(const UniConfKey &key)
Determines if a key is a mountpoint.
virtual bool refresh()
Refreshes information about a key recursively.
virtual void setv(const UniConfPairList &pairs)
Stores multiple key-value pairs into the registry.
UniMountGen()
Creates an empty UniConf tree with no mounted stores.
virtual Iter * iterator(const UniConfKey &key)
Returns an iterator over the children of the specified key.
virtual IUniConfGen * mount(const UniConfKey &key, WvStringParm moniker, bool refresh)
Mounts a generator at a key using a moniker.
virtual ~UniMountGen()
Destroys the UniConf tree along with all uncommitted data.
virtual bool haschildren(const UniConfKey &key)
Returns true if a key has children.
UniMountGen(const UniMountGen &other)
undefined.
virtual void flush_buffers()
Flushes any commitment/notification buffers .
virtual void set(const UniConfKey &key, WvStringParm value)
Stores a string value for a key into the registry.
virtual bool exists(const UniConfKey &key)
Without fetching its value, returns true if a key exists.
virtual WvString get(const UniConfKey &key)
Fetches a string value for a key from the registry.
virtual void unmount(IUniConfGen *gen, bool commit)
Unmounts the generator at a key and releases it.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition wvstring.h:94
A linked list container class.
Definition wvlinklist.h:198
WvString is an implementation of a simple and efficient printable-string class.
Definition wvstring.h:330
Smart pointer class for XPLC interfaces.
Definition ptr.h:56