CARMA C++
Control.h
Go to the documentation of this file.
1 #ifndef SZA_UTIL_CONTROL_H
2 #define SZA_UTIL_CONTROL_H
3 
11 #include "carma/szautil/FdSet.h"
12 #include "carma/szautil/NetStr.h"
14 #include "carma/szautil/SzaPorts.h"
16 
17 namespace sza {
18  namespace util {
19 
20  class Control {
21  public:
22 
26  Control(std::string host, bool log);
27 
28  // Non-interactive constructor
29 
30  Control(std::string host);
31  void sendCommand(std::string command);
32  void disconnect();
33 
37  void processCommands();
38  void processMessages();
39  void readMessage();
40 
44  virtual ~Control();
45 
46  private:
47 
48  // A static pointer to ourselves for use in handlers
49 
50  static Control* control_;
51 
52  // An object for handling signals
53 
54  SignalTask signalTask_;
55 
56  // A client object for managing our connection to the control program
57 
58  TcpClient client_;
59 
60  // A network buffer for communication with the control program
61 
62  NetStr netStr_;
63 
64  // A set of file descriptors
65 
66  FdSet fdSet_;
67 
68  // True when we should exit.
69 
70  bool stop_;
71 
72  // Thread management objects
73 
74  Thread* readThread_;
75 
76  static THREAD_START(startRead);
77 
78  Thread* sendThread_;
79 
80  static THREAD_START(startSend);
81 
85  void readCommand();
86 
90  void sendCommand();
91 
95  static SIGNALTASK_HANDLER_FN(exitHandler);
96 
100  static NET_SEND_HANDLER(sendHandler);
101 
105  static NET_READ_HANDLER(readHandler);
106 
111  static NET_SEND_HANDLER(errorHandler);
112 
113  }; // End class Control
114 
115  } // End namespace util
116 } // End namespace sza
117 
118 
119 
120 #endif // End #ifndef SZA_UTIL_CONTROL_H
Started: Tue Mar 2 03:37:15 UTC 2004.
Tagged: Fri Nov 14 12:39:36 UTC 2003.
Started: Sat Mar 6 14:44:17 UTC 2004.
Started: Thu Feb 26 22:08:23 UTC 2004.