Fix several warnings that appear in gcc 4.3.2.
[wvstreams.git] / include / unireplicategen.h
blob148be4b82cca4cf8e182b1513722f0b008caf26b
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2002 Net Integration Technologies, Inc.
5 * A UniConf generator that caches keys/values in memory.
6 */
7 #ifndef __UNIREPLICATEGEN_H
8 #define __UNIREPLICATEGEN_H
10 #include "uniconftree.h"
11 #include "wvlog.h"
13 /**
14 * A UniConf generator that replicates generators between an ordered list
15 * of inner generators, with the priority given by the list.
17 * Replication of the data occurs when the generator is contructed, whenever
18 * prepend() or append() is called, or whenever any of the generators in the
19 * list goes from !isok() to isok(). If two inner generators contain different
20 * values for the same before replication, then they will both have the value
21 * of the earlier generator (as ordered in the moniker) after replication.
23 * If an asynchronous change occurs in any of the inner generators, the
24 * new value will be set in all generators irrespective of priority.
26 class UniReplicateGen : public UniConfGen
28 private:
29 struct Gen
31 IUniConfGen *gen;
32 bool was_ok;
33 bool auto_free;
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); }
39 bool isok() { return was_ok = gen->isok(); }
41 DeclareWvList(Gen);
42 GenList gens;
44 bool processing_callback;
46 Gen *first_ok() const;
48 void replicate_if_any_have_become_ok();
50 protected:
51 void replicate(const UniConfKey &key = "/");
52 void deltacallback(Gen *src_gen, const UniConfKey &key,
53 WvStringParm value);
55 public:
56 UniReplicateGen();
57 UniReplicateGen(const IUniConfGenList &_gens, bool autofree = true);
58 virtual ~UniReplicateGen();
60 void prepend(IUniConfGen *gen, bool autofree = true);
61 void append(IUniConfGen *gen, bool autofree = true);
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);
74 #endif // __UNIREPLICATEGEN_H