WvStreams
debian/libwvstreams-dev/usr/include/wvstreams/unireplicategen.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2002 Net Integration Technologies, Inc.
4 *
5 * A UniConf generator that caches keys/values in memory.
6 */
7#ifndef __UNIREPLICATEGEN_H
8#define __UNIREPLICATEGEN_H
9
10#include "uniconftree.h"
11#include "wvlog.h"
12
27{
28private:
29 struct Gen
30 {
31 IUniConfGen *gen;
32 bool was_ok;
33 bool auto_free;
34
35 Gen(IUniConfGen *_gen, bool _auto_free)
36 : gen(_gen), was_ok(gen->isok()), auto_free(_auto_free) {}
37 ~Gen() { if (auto_free) WVRELEASE(gen); }
38
39 bool isok() { return was_ok = gen->isok(); }
40 };
41 DeclareWvList(Gen);
42 GenList gens;
43
44 bool processing_callback;
45
46 Gen *first_ok() const;
47
48 void replicate_if_any_have_become_ok();
49
50protected:
51 void replicate(const UniConfKey &key = "/");
52 void deltacallback(Gen *src_gen, const UniConfKey &key,
53 WvStringParm value);
54
55public:
57 UniReplicateGen(const IUniConfGenList &_gens, bool autofree = true);
58 virtual ~UniReplicateGen();
59
60 void prepend(IUniConfGen *gen, bool autofree = true);
61 void append(IUniConfGen *gen, bool autofree = true);
62
63 /***** Overridden members *****/
64 virtual bool isok();
65 virtual void commit();
66 virtual bool refresh();
67 virtual void flush_buffers() { }
68 virtual void set(const UniConfKey &key, WvStringParm value);
69 virtual void setv(const UniConfPairList &pairs);
70 virtual WvString get(const UniConfKey &key);
71 virtual Iter *iterator(const UniConfKey &key);
72};
73
74#endif // __UNIREPLICATEGEN_H
An abstract data container that backs a UniConf tree.
virtual bool isok()=0
Determines if the generator is usable and working properly.
A default implementation of IUniConfGen, providing various handy features that save trouble when impl...
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
A UniConf generator that replicates generators between an ordered list of inner generators,...
virtual Iter * iterator(const UniConfKey &key)
Returns an iterator over the children of the specified key.
virtual void commit()
Commits any changes.
virtual bool refresh()
Refreshes information about a key recursively.
virtual WvString get(const UniConfKey &key)
Fetches a string value for a key from the registry.
virtual void setv(const UniConfPairList &pairs)
Stores multiple key-value pairs into the registry.
virtual bool isok()
Determines if the generator is usable and working properly.
virtual void flush_buffers()
Flushes any commitment/notification buffers .
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
WvString is an implementation of a simple and efficient printable-string class.