00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 2002 Net Integration Technologies, Inc. 00004 * 00005 * A UniConfGen framework to simplify writing filtering generators. 00006 */ 00007 #ifndef __UNIFILTERGEN_H 00008 #define __UNIFILTERGEN_H 00009 00010 #include "uniconfgen.h" 00011 00012 /** 00013 * A UniConfGen that delegates all requests to an inner generator. If you 00014 * derive from this, you can selectively override particular behaviours 00015 * of a sub-generator. 00016 */ 00017 class UniFilterGen : public UniConfGen 00018 { 00019 UniConfGen *xinner; 00020 00021 protected: 00022 UniFilterGen(UniConfGen *inner); 00023 virtual ~UniFilterGen(); 00024 00025 /** 00026 * Rebinds the inner generator and prepares its callback. 00027 * The previous generator is NOT destroyed. 00028 * "inner" must not be null. 00029 */ 00030 void setinner(UniConfGen *inner); 00031 00032 public: 00033 /** 00034 * Returns the inner generator. 00035 */ 00036 UniConfGen *inner() const 00037 { return xinner; } 00038 00039 /***** Overridden methods *****/ 00040 00041 virtual void commit(); 00042 virtual bool refresh(); 00043 virtual WvString get(const UniConfKey &key); 00044 virtual void set(const UniConfKey &key, WvStringParm value); 00045 virtual bool exists(const UniConfKey &key); 00046 virtual bool haschildren(const UniConfKey &key); 00047 virtual bool isok(); 00048 virtual Iter *iterator(const UniConfKey &key); 00049 00050 protected: 00051 /** 00052 * Called by inner generator when a key changes. 00053 * The default implementation calls delta(key). 00054 */ 00055 virtual void gencallback(const UniConfKey &key, WvStringParm value, 00056 void *userdata); 00057 }; 00058 00059 #endif //__UNIFILTERGEN_H