WvStreams
wvstreamsdaemon.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Tunnel Vision Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * High-level abstraction for creating daemon processes that do
6  * nothing but listen on a list of WvStreams and add connections
7  * to the global list.
8  */
9 #ifndef __WVSTREAMSDAEMON_H
10 #define __WVSTREAMSDAEMON_H
11 
12 #include "wvdaemon.h"
13 #include "iwvstream.h"
14 #include "wvistreamlist.h"
15 
30 class WvStreamsDaemon : public WvDaemon
31 {
32 private:
33 
34  WvDaemonCallback callback;
35 
36  bool do_full_close;
37  WvIStreamList streams;
38 
39  void init(WvDaemonCallback cb);
40 
41 protected:
42 
43  virtual void do_start();
44  virtual void do_run();
45  virtual void do_stop();
46 
47 private:
48 
49  void restart_close_cb(IWvStream *s, const char *id);
50  void die_close_cb(IWvStream *s, const char *id);
51 
52 public:
53 
56  WvStreamsDaemon(WvStringParm name,
57  WvStringParm version,
58  WvDaemonCallback cb) :
59  WvDaemon(name, version, WvDaemonCallback(),
60  WvDaemonCallback(), WvDaemonCallback())
61  {
62  init(cb);
63  }
64 
68  void add_stream(IWvStream *istream,
69  bool auto_free, const char *id);
75  void add_restart_stream(IWvStream *istream,
76  bool auto_free, const char *id);
81  void add_die_stream(IWvStream *istream,
82  bool auto_free, const char *id);
83 
88  {
89  do_full_close = true;
90  }
91 
93  void setcallback(WvDaemonCallback cb);
94 
95 private:
99  void add_stream(IWvStream *istream, bool auto_free, WvString id);
100  void add_restart_stream(IWvStream *istream, bool auto_free, WvString id);
101  void add_die_stream(IWvStream *istream, bool auto_free, WvString id);
102 public:
103  const char *wstype() const { return "WvStreamsDaemon"; }
104 };
105 #endif // __WVSTREAMSDAEMON_H
WvStreamsDaemon::close_existing_connections_on_restart
void close_existing_connections_on_restart()
If this member is called then any existing streams on the globallist added after the WvDaemonCallback...
Definition: wvstreamsdaemon.h:87
WvStreamsDaemon::add_stream
void add_stream(IWvStream *istream, bool auto_free, const char *id)
Add a stream to the daemon; don't do anything if it goes !isok().
Definition: wvstreamsdaemon.cc:59
IWvStream
Definition: iwvstream.h:24
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvStreamsDaemon::add_restart_stream
void add_restart_stream(IWvStream *istream, bool auto_free, const char *id)
Add a stream to the daemon; the daemon will restart, re-populating the initial streams using the call...
Definition: wvstreamsdaemon.cc:68
WvStreamsDaemon::WvStreamsDaemon
WvStreamsDaemon(WvStringParm name, WvStringParm version, WvDaemonCallback cb)
Construct a new WvStreamsDaemon with given name and version, and use the cb function to populate the ...
Definition: wvstreamsdaemon.h:56
WvStreamsDaemon::setcallback
void setcallback(WvDaemonCallback cb)
Change the callback function and userdata.
Definition: wvstreamsdaemon.cc:108
WvStreamsDaemon
WvStreamsDaemon - High-level abstraction for a daemon process that does nothing but add streams to th...
Definition: wvstreamsdaemon.h:30
WvDaemon::name
WvString name
The name and version of the daemon; used for -V and logging.
Definition: wvdaemon.h:93
WvDaemon
WvDaemon - High-level abstraction for creating daemon processes.
Definition: wvdaemon.h:85
WvIStreamList
WvStreamList holds a list of WvStream objects – and its select() and callback() functions know how to...
Definition: wvistreamlist.h:20
WvStreamsDaemon::add_die_stream
void add_die_stream(IWvStream *istream, bool auto_free, const char *id)
Add a stream to the daemon; if the stream goes !isok() the daemon will exit.
Definition: wvstreamsdaemon.cc:77