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