2 * Worldvisions Weaver Software:
3 * Copyright (C) 2002 Net Integration Technologies, Inc.
5 * A UniConf generator that caches keys/values in memory.
7 #ifndef __UNIREPLICATEGEN_H
8 #define __UNIREPLICATEGEN_H
10 #include "uniconftree.h"
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
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(); }
44 bool processing_callback
;
46 Gen
*first_ok() const;
48 void replicate_if_any_have_become_ok();
51 void replicate(const UniConfKey
&key
= "/");
52 void deltacallback(Gen
*src_gen
, const UniConfKey
&key
,
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 *****/
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