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
31{
32private:
33
34 WvDaemonCallback callback;
35
36 bool do_full_close;
37 WvIStreamList streams;
38
39 void init(WvDaemonCallback cb);
40
41protected:
42
43 virtual void do_start();
44 virtual void do_run();
45 virtual void do_stop();
46
47private:
48
49 void restart_close_cb(IWvStream *s, const char *id);
50 void die_close_cb(IWvStream *s, const char *id);
51
52public:
53
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
95private:
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);
102public:
103 const char *wstype() const { return "WvStreamsDaemon"; }
104};
105#endif // __WVSTREAMSDAEMON_H
WvDaemon - High-level abstraction for creating daemon processes.
Definition: wvdaemon.h:86
WvString name
The name and version of the daemon; used for -V and logging.
Definition: wvdaemon.h:93
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition: wvstring.h:94
WvStreamList holds a list of WvStream objects – and its select() and callback() functions know how to...
Definition: wvistreamlist.h:21
WvStreamsDaemon - High-level abstraction for a daemon process that does nothing but add streams to th...
void setcallback(WvDaemonCallback cb)
Change the callback function and userdata.
WvStreamsDaemon(WvStringParm name, WvStringParm version, WvDaemonCallback cb)
Construct a new WvStreamsDaemon with given name and version, and use the cb function to populate the ...
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...
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.
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().
void close_existing_connections_on_restart()
If this member is called then any existing streams on the globallist added after the WvDaemonCallback...
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:330