FACT++  1.0
DimNetwork.h
Go to the documentation of this file.
1 #ifndef FACT_DimNetwork
2 #define FACT_DimNetwork
3 
4 // **************************************************************************
14 // **************************************************************************
15 #include "MessageDim.h"
16 #include "Time.h"
17 
18 class StateClient : public MessageDimRX
19 {
20 private:
22  int fState;
23 
25 
26 protected:
27  void infoHandler();
28 
29 public:
30  StateClient(const std::string &name, MessageImp &imp);
31 
32  bool IsConnected() const { return fState>=0; }
33  int GetState() const { return fState; }
34 
35  const char *GetName() const { return const_cast<DimStampedInfo&>(fInfoState).getName(); }
36 };
37 
38 
39 
40 // **************************************************************************
55 // **************************************************************************
56 #include "DimServiceInfoList.h"
57 #include "DimErrorRedirecter.h"
58 
59 using namespace std;
60 
62 {
63 private:
64  void DeleteClientList();
65 
66 protected:
67  typedef std::map<const std::string, StateClient*> ClientList;
68 
69  ClientList fClientList;
70 
71  void AddServer(const std::string &s);
72  void RemoveServer(std::string s);
73  void RemoveAllServers();
74 
75 public:
76  DimNetwork(std::ostream &out=std::cout)
77  : MessageImp(out), DimErrorRedirecter(static_cast<MessageImp&>(*this))
78  {
79  }
81  {
82  DeleteClientList();
83  }
84 
85  int GetCurrentState(const string &server) const;
86 };
87 
88 
89 #endif
A base class taking care of padding, exit handler and error handlers.
The base implementation of a distributed messaging system.
Definition: MessageImp.h:10
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
const char * GetName() const
Definition: DimNetwork.h:35
STL namespace.
DimStampedInfo fInfoState
-2 not initialized, -1 not connected, 0>= state of client
Definition: DimNetwork.h:24
int GetState() const
Definition: DimNetwork.h:33
std::map< const std::string, StateClient * > ClientList
Definition: DimNetwork.h:67
Time fStateTime
Definition: DimNetwork.h:21
Implements automatic subscription to MESSAGE and STATE services.
Definition: DimNetwork.h:61
ClientList fClientList
Definition: DimNetwork.h:69
StateClient(const std::string &name, MessageImp &imp)
Definition: DimNetwork.cc:3
bool IsConnected() const
Definition: DimNetwork.h:32
Based on MessageImp, subscribes to a MESSAGE service in the Dim network.
Definition: MessageDim.h:34
DimNetwork(std::ostream &out=std::cout)
Definition: DimNetwork.h:76
void infoHandler()
The dim service subscription.
Definition: DimNetwork.cc:14
int fState
Combine into one MTime (together with value)
Definition: DimNetwork.h:22
A simple Dim client diriving from MessageDimRX subscribing to the STATE service.
Definition: DimNetwork.h:18