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 
17 class UniMountGen : public UniConfGen
18 {
19 protected:
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 
39 public:
41  UniMountGen();
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 
109 private:
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
UniMountGen::~UniMountGen
virtual ~UniMountGen()
Destroys the UniConf tree along with all uncommitted data.
Definition: unimountgen.cc:23
UniMountGen::ismountpoint
virtual bool ismountpoint(const UniConfKey &key)
Determines if a key is a mountpoint.
Definition: unimountgen.cc:290
UniConfKey::removefirst
UniConfKey removefirst(int n=1) const
Returns the path formed by removing the first n segments of this path.
Definition: uniconfkey.h:335
UniMountGen::mount
virtual IUniConfGen * mount(const UniConfKey &key, WvStringParm moniker, bool refresh)
Mounts a generator at a key using a moniker.
Definition: unimountgen.cc:176
UniMountGen::get
virtual WvString get(const UniConfKey &key)
Fetches a string value for a key from the registry.
Definition: unimountgen.cc:29
UniMountGen::refresh
virtual bool refresh()
Refreshes information about a key recursively.
Definition: unimountgen.cc:149
UniMountGen::flush_buffers
virtual void flush_buffers()
Flushes any commitment/notification buffers .
Definition: unimountgen.h:105
UniMountGen::UniMountGen
UniMountGen()
Creates an empty UniConf tree with no mounted stores.
Definition: unimountgen.cc:17
UniMountGen::setv
virtual void setv(const UniConfPairList &pairs)
Stores multiple key-value pairs into the registry.
Definition: unimountgen.cc:70
UniMountGen::whichmount
virtual IUniConfGen * whichmount(const UniConfKey &key, UniConfKey *mountpoint)
Finds the generator that owns a key.
Definition: unimountgen.cc:271
UniMountGen::haschildren
virtual bool haschildren(const UniConfKey &key)
Returns true if a key has children.
Definition: unimountgen.cc:113
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
IUniConfGen
An abstract data container that backs a UniConf tree.
Definition: uniconfgen.h:39
UniConfKey
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
Definition: uniconfkey.h:38
UniMountGen::UniGenMount
Definition: unimountgen.h:22
UniMountGen::commit
virtual void commit()
Commits any changes.
Definition: unimountgen.cc:164
UniMountGen::unmount
virtual void unmount(IUniConfGen *gen, bool commit)
Unmounts the generator at a key and releases it.
Definition: unimountgen.cc:219
UniMountGen::mountgen
virtual IUniConfGen * mountgen(const UniConfKey &key, IUniConfGen *gen, bool refresh)
Mounts a generator at a key.
Definition: unimountgen.cc:191
UniMountGen::recursiveiterator
virtual Iter * recursiveiterator(const UniConfKey &key)
Like iterator(), but the returned iterator is recursive, that is, it will return children of the imme...
Definition: unimountgen.cc:348
UniMountGen::set
virtual void set(const UniConfKey &key, WvStringParm value)
Stores a string value for a key into the registry.
Definition: unimountgen.cc:46
UniConfGen
A default implementation of IUniConfGen, providing various handy features that save trouble when impl...
Definition: uniconfgen.h:199
UniMountGen::exists
virtual bool exists(const UniConfKey &key)
Without fetching its value, returns true if a key exists.
Definition: unimountgen.cc:100
WvList::zap
void zap(bool destroy=true)
Clears the linked list.
Definition: wvlinklist.h:228
xplc_ptr< IUniConfGen >
UniMountGen
The UniMountTree implementation realized as a UniConfGen.
Definition: unimountgen.h:17
UniMountGen::iterator
virtual Iter * iterator(const UniConfKey &key)
Returns an iterator over the children of the specified key.
Definition: unimountgen.cc:308
UniConfKey::numsegments
int numsegments() const
Returns the number of segments in this path.
Definition: uniconfkey.h:287
WvFastString
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition: wvstring.h:93
WvList
A linked list container class.
Definition: wvlinklist.h:197