WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * A class that does add_callback when created and del_callback when 00006 * destroyed, thus making it harder to do one or the other incorrectly. 00007 * 00008 * Because it's an object itself, it uses its own 'this' pointer as the 00009 * 'cookie', so you don't have to come up with one. 00010 */ 00011 #ifndef __UNIWATCH_H 00012 #define __UNIWATCH_H 00013 00014 #include "uniconf.h" 00015 00016 class UniWatch 00017 { 00018 UniConf cfg; 00019 UniConfCallback cb; 00020 bool recurse; 00021 00022 public: 00023 // standard "add_callback" version 00024 UniWatch(const UniConf &_cfg, const UniConfCallback &_cb, 00025 bool _recurse = true); 00026 00027 // special "add_setbool" version 00028 UniWatch(const UniConf &_cfg, bool *b, bool _recurse = true); 00029 00030 ~UniWatch(); 00031 }; 00032 00033 DeclareWvList2(UniWatchListBase, UniWatch); 00034 00035 class UniWatchList : public UniWatchListBase 00036 { 00037 public: 00038 void add(const UniConf &_cfg, const UniConfCallback &_cb, 00039 bool _recurse = true) 00040 { append(new UniWatch(_cfg, _cb, _recurse), true); } 00041 void add(const UniConf &_cfg, bool *b, bool _recurse = true) 00042 { append(new UniWatch(_cfg, b, _recurse), true); } 00043 }; 00044 00045 00046 #endif // __UNIWATCH_H