Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

uniclientgen.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * UniClientGen is a UniConfGen for retrieving data from the 00006 * UniConfDaemon. 00007 */ 00008 #ifndef __UNICONFCLIENT_H 00009 #define __UNICONFCLIENT_H 00010 00011 #include "uniconfgen.h" 00012 #include "wvlog.h" 00013 #include "wvstringlist.h" 00014 #include "uniclientconn.h" 00015 00016 00017 /** 00018 * Communicates with a UniConfDaemon to fetch and store keys and 00019 * values. 00020 * 00021 * To mount, use the moniker prefix "unix:" followed by the 00022 * path of the Unix domain socket used by the UniConfDaemon. 00023 * Alternately, use the moniker prefix "tcp:" followed by the 00024 * hostname, a colon, and the port of a machine that serves 00025 * UniConfDaemon requests over TCP. 00026 * 00027 */ 00028 class UniClientGen : public UniConfGen 00029 { 00030 class RemoteKeyIter; 00031 00032 UniClientConn *conn; 00033 00034 /* 00035 * To make sure we don't deliver notifications while we're already in the 00036 * callback (as this could result in trying to call it again before 00037 * completion), we instead have an empty stream handle this using alarm(0). 00038 */ 00039 UniConfPairList deltas; 00040 WvStream deltastream; 00041 00042 //WvStringList set_queue; 00043 WvLog log; 00044 00045 WvString result_key; /*!< the key that the current result is from */ 00046 WvString result; /*!< the result from the current key */ 00047 WvStringList *result_list; /*!< result list for iterations */ 00048 00049 bool cmdinprogress; /*!< true while a command is in progress */ 00050 bool cmdsuccess; /*!< true when a command completed successfully */ 00051 00052 static const int TIMEOUT = 1000; // 1 sec timeout 00053 00054 public: 00055 /** 00056 * Creates a generator which can communicate with a daemon using 00057 * the specified stream. 00058 * "stream" is the raw connection 00059 */ 00060 UniClientGen(IWvStream *stream, WvStringParm dst = WvString::null); 00061 00062 virtual ~UniClientGen(); 00063 00064 /***** Overridden members *****/ 00065 00066 virtual bool isok(); 00067 00068 virtual bool refresh(); 00069 virtual WvString get(const UniConfKey &key); 00070 virtual void set(const UniConfKey &key, WvStringParm value); 00071 virtual bool haschildren(const UniConfKey &key); 00072 virtual Iter *iterator(const UniConfKey &key); 00073 00074 protected: 00075 void conncallback(WvStream &s, void *userdata); 00076 bool do_select(); 00077 void clientdelta(const UniConfKey &key, WvStringParm value); 00078 void deltacb(WvStream &, void *); 00079 }; 00080 00081 00082 /** An iterator over remote keys. */ 00083 class UniClientGen::RemoteKeyIter : public UniClientGen::Iter 00084 { 00085 protected: 00086 WvStringList *list; 00087 WvStringList::Iter i; 00088 00089 public: 00090 RemoteKeyIter(WvStringList *_list) : list(_list), i(*_list) { } 00091 virtual ~RemoteKeyIter() { delete list; } 00092 00093 /***** Overridden methods *****/ 00094 00095 virtual void rewind(); 00096 virtual bool next(); 00097 virtual UniConfKey key() const; 00098 }; 00099 00100 #endif // __UNICONFCLIENT_H

Generated on Tue Oct 5 01:09:19 2004 for WvStreams by doxygen 1.3.7