00001
00002
00003
00004
00005
00006
00007 #ifndef __UNIREPLICATEGEN_H
00008 #define __UNIREPLICATEGEN_H
00009
00010 #include "uniconftree.h"
00011 #include "wvlog.h"
00012
00026 class UniReplicateGen : public UniConfGen
00027 {
00028 private:
00029 struct Gen
00030 {
00031 IUniConfGen *gen;
00032 bool was_ok;
00033 bool auto_free;
00034
00035 Gen(IUniConfGen *_gen, bool _auto_free)
00036 : gen(_gen), was_ok(gen->isok()), auto_free(_auto_free) {}
00037 ~Gen() { if (auto_free) WVRELEASE(gen); }
00038
00039 bool isok() { return was_ok = gen->isok(); }
00040 };
00041 DeclareWvList(Gen);
00042 GenList gens;
00043
00044 bool processing_callback;
00045
00046 Gen *first_ok() const;
00047
00048 void replicate_if_any_have_become_ok();
00049
00050 protected:
00051 void replicate(const UniConfKey &key = "/");
00052 void deltacallback(Gen *src_gen, const UniConfKey &key,
00053 WvStringParm value);
00054
00055 public:
00056 UniReplicateGen();
00057 UniReplicateGen(const IUniConfGenList &_gens, bool autofree = true);
00058 virtual ~UniReplicateGen();
00059
00060 void prepend(IUniConfGen *gen, bool autofree = true);
00061 void append(IUniConfGen *gen, bool autofree = true);
00062
00063
00064 virtual bool isok();
00065 virtual void commit();
00066 virtual bool refresh();
00067 virtual void flush_buffers() { }
00068 virtual void set(const UniConfKey &key, WvStringParm value);
00069 virtual void setv(const UniConfPairList &pairs);
00070 virtual WvString get(const UniConfKey &key);
00071 virtual Iter *iterator(const UniConfKey &key);
00072 };
00073
00074 #endif // __UNIREPLICATEGEN_H