IFEM  90A354
ControlFIFO.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef CONTROL_FIFO_H_
15 #define CONTROL_FIFO_H_
16 
17 #include <string>
18 #include <map>
19 
20 namespace tinyxml2 { class XMLElement; }
21 
22 
28 {
29 public:
31  virtual void OnControl(const tinyxml2::XMLElement* context) = 0;
33  virtual std::string GetContext() const = 0;
34 };
35 
36 
45 {
46 public:
48  ControlFIFO() : fifo(-1) {}
49 
51  ~ControlFIFO();
52 
55  void registerCallback(ControlCallback& callback);
56 
59  bool open(const char* name = "ifem-control");
60 
62  void poll();
63 
64 private:
65  std::string fifo_name;
66  int fifo;
67 
68  std::map<std::string,ControlCallback*> callbacks;
69 };
70 
71 #endif
Callback for FIFO option handling.
Definition: ControlFIFO.h:28
virtual void OnControl(const tinyxml2::XMLElement *context)=0
Callback on receiving a XML control block.
virtual std::string GetContext() const =0
Returns context name for callback.
This class enables simple application control over a FIFO.
Definition: ControlFIFO.h:45
int fifo
fifo handle
Definition: ControlFIFO.h:66
ControlFIFO()
Default constructor.
Definition: ControlFIFO.h:48
~ControlFIFO()
The destructor tears down the opened fifo and removes the file.
Definition: ControlFIFO.C:24
void registerCallback(ControlCallback &callback)
Registers a callback handler.
Definition: ControlFIFO.C:80
void poll()
Polls for new data in the fifo.
Definition: ControlFIFO.C:51
std::string fifo_name
Name of filesystem entry of our fifo.
Definition: ControlFIFO.h:65
bool open(const char *name="ifem-control")
Opens the fifo and prepares for receiving.
Definition: ControlFIFO.C:34
std::map< std::string, ControlCallback * > callbacks
Registered callbacks.
Definition: ControlFIFO.h:68