WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * FIXME: Suspiciously similar to wvstreamlist, and with tons of duplicated 00006 * code. Blech. 00007 */ 00008 #ifndef __WVISTREAMLIST_H 00009 #define __WVISTREAMLIST_H 00010 00011 #include "wvstream.h" 00012 00014 DeclareWvList2(WvIStreamListBase, IWvStream); 00015 00020 class WvIStreamList : public WvStream, public WvIStreamListBase 00021 { 00022 public: 00023 WvIStreamList(); 00024 virtual ~WvIStreamList(); 00025 virtual bool isok() const; 00026 virtual void pre_select(SelectInfo &si); 00027 virtual bool post_select(SelectInfo &si); 00028 virtual void execute(); 00029 00030 void unlink(IWvStream *data) 00031 { sure_thing.unlink(data); WvIStreamListBase::unlink(data); } 00032 00033 void add_after(WvLink *after, IWvStream *data, bool autofree, 00034 const char *id) 00035 { 00036 WvIStreamListBase::add_after(after, data, autofree, id); 00037 } 00038 void add(IWvStream *data, bool autofree, const char *id) 00039 { 00040 WvIStreamListBase::add(data, autofree, id); 00041 } 00042 void prepend(IWvStream *data, bool autofree, const char *id) 00043 { 00044 WvIStreamListBase::prepend(data, autofree, id); 00045 } 00046 00047 public: 00048 bool auto_prune; // remove !isok() streams from the list automatically? 00049 static WvIStreamList globallist; 00050 00051 protected: 00052 WvIStreamListBase sure_thing; 00053 00054 private: 00055 // Create some undefined overrides to prevent accidentally using a 00056 // WvString as an id; these functions will keep a long-term reference to 00057 // the string, so you should probably use a string constant. 00058 void add_after(WvLink *after, IWvStream *data, bool autofree, WvString id); 00059 void add(IWvStream *data, bool autofree, WvString id); 00060 void prepend(IWvStream *data, bool autofree, WvString id); 00061 00062 private: 00063 bool in_select; 00064 bool dead_stream; 00065 00066 #ifndef _WIN32 00067 static void onfork(pid_t p); 00068 #endif 00069 00070 public: 00071 void append(IWvStream *s, bool auto_free, const char *id) 00072 { 00073 if (s->wsname() == NULL) 00074 s->set_wsname(id); 00075 WvIStreamListBase::append(s, auto_free, id); 00076 } 00077 void append(IWvStream *s, bool auto_free, WVSTRING_FORMAT_DECL) 00078 { 00079 if (s->wsname() == NULL) 00080 s->set_wsname(WvString(WVSTRING_FORMAT_CALL)); 00081 WvIStreamListBase::append(s, auto_free, s->wsname()); 00082 } 00083 00084 public: 00085 const char *wstype() const { return "WvIStreamList"; } 00086 00087 private: 00088 static void add_debugger_commands(); 00089 private: 00090 static WvString debugger_globallist_run_cb(WvStringParm cmd, 00091 WvStringList &args, 00092 WvStreamsDebugger::ResultCallback result_cb, void *); 00093 }; 00094 00095 #endif // __WVISTREAMLIST_H