00001
00002
00003
00004
00005
00006
00007
#ifndef __UNIMOUNTTREEGEN_H
00008
#define __UNIMOUNTTREEGEN_H
00009
00010
#include "uniconfgen.h"
00011
#include "uniconftree.h"
00012
#include "wvcallback.h"
00013
#include "wvstringtable.h"
00014
#include "wvmoniker.h"
00015
00016
00017
00018
00019
00020 class UniMountTree :
public UniConfTree<UniMountTree>
00021 {
00022
public:
00023 UniConfGenList
generators;
00024
00025
UniMountTree(
UniMountTree *parent,
const UniConfKey &key);
00026
~UniMountTree();
00027
00028
00029 bool isessential()
00030 {
return haschildren() || !
generators.isempty(); }
00031
00032
00033
00034
00035
00036
00037
00038
UniMountTree *findnearest(
const UniConfKey &key,
int &split);
00039
00040
00041
UniMountTree *findormake(
const UniConfKey &key);
00042
00043
00044
class MountIter;
00045
00046
class GenIter;
00047 };
00048
00049
00050
00051
00052
00053
00054
00055 class UniMountTree::MountIter
00056 {
00057
int bestsplit;
00058
UniMountTree *bestnode;
00059
00060
int xsplit;
00061
UniMountTree *xnode;
00062
UniConfKey xkey;
00063
00064
public:
00065
MountIter(
UniMountTree &root,
const UniConfKey &
key);
00066
00067
void rewind();
00068
bool next();
00069
00070 int split()
const
00071
{
return xsplit; }
00072 UniConfKey key()
const
00073
{
return xkey; }
00074 UniConfKey head()
const
00075
{
return xkey.
first(xsplit); }
00076 UniConfKey tail()
const
00077
{
return xkey.
removefirst(xsplit); }
00078 UniMountTree *
node()
const
00079
{
return xnode; }
00080 UniMountTree *
ptr()
const
00081
{
return node(); }
00082
WvIterStuff(
UniMountTree);
00083 };
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 class UniMountTree::GenIter :
private UniMountTree::
MountIter
00096 {
00097 UniConfGenList::Iter *genit;
00098
00099
public:
00100
GenIter(
UniMountTree &root,
const UniConfKey &key);
00101 ~
GenIter();
00102
00103 typedef UniMountTree::MountIter ParentClass;
00104
using ParentClass::split;
00105
using ParentClass::key;
00106
using ParentClass::head;
00107
using ParentClass::tail;
00108
using ParentClass::node;
00109
00110
void rewind();
00111
bool next();
00112
00113 UniConfGen *ptr()
const
00114
{
return genit ? genit->ptr() : NULL; }
00115
WvIterStuff(
UniConfGen);
00116 };
00117
00118
00119
00120 class UniMountTreeGen :
public UniConfGen
00121 {
00122
class KeyIter;
00123
friend class KeyIter;
00124
00125
UniMountTree *mounts;
00126
00127
00128
UniMountTreeGen(
const UniMountTreeGen &other);
00129
00130
public:
00131
00132
UniMountTreeGen();
00133
00134
00135 ~
UniMountTreeGen();
00136
00137
00138
00139
00140
00141
00142
virtual UniConfGen *mount(
const UniConfKey &key,
WvStringParm moniker,
00143
bool refresh);
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
virtual UniConfGen *mountgen(
const UniConfKey &key,
UniConfGen *gen,
00155
bool refresh);
00156
00157
00158
00159
00160
00161
00162
00163
00164
virtual void unmount(
const UniConfKey &key,
UniConfGen *gen,
bool commit);
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
virtual UniConfGen *whichmount(
const UniConfKey &key,
UniConfKey *mountpoint);
00179
00180
00181
virtual bool ismountpoint(
const UniConfKey &key);
00182
00183
00184
00185
virtual bool exists(
const UniConfKey &key);
00186
virtual bool haschildren(
const UniConfKey &key);
00187
virtual WvString get(
const UniConfKey &key);
00188
virtual void set(
const UniConfKey &key,
WvStringParm value);
00189
virtual bool refresh();
00190
virtual void commit();
00191
virtual Iter *iterator(
const UniConfKey &key);
00192
00193
private:
00194
00195
00196
00197
00198
00199
void prune(
UniMountTree *node);
00200
00201
00202
void gencallback(
const UniConfKey &key,
WvStringParm value,
void *userdata);
00203 };
00204
00205
00206
00207
00208
00209 class UniMountTreeGen::KeyIter :
public UniConfGen::Iter
00210 {
00211
UniMountTreeGen *xroot;
00212
UniConfKey xkey;
00213
00214
UniMountTree::GenIter genit;
00215
WvStringTable hack;
00216 WvStringTable::Iter hackit;
00217
00218
public:
00219
KeyIter(
UniMountTreeGen &root,
const UniConfKey &key);
00220
00221
00222
00223
virtual void rewind();
00224
virtual bool next();
00225
virtual UniConfKey key()
const;
00226 };
00227
00228
#endif //__UNIMOUNTTREEGEN_H