FACT++  1.0
DimState.cc
Go to the documentation of this file.
1 #include "DimState.h"
2 
3 using namespace std;
4 using namespace boost;
5 
7 {
8  if (evt.GetSize()==0)
9  return;
10 
11  time = evt.GetTime();
12  msg = evt.GetString();
13 
14  typedef char_separator<char> separator;
15  const tokenizer<separator> tok(msg, separator("|"));
16 
17  for (auto it=tok.begin(); it!=tok.end(); it++)
18  {
19  const size_t p = it->find_first_of('@');
20  if (p==string::npos)
21  continue;
22 
23  // The first part before the first @ is the server name
24  string server = it->substr(0, p);
25  if (server.empty())
26  continue;
27 
28  // If it starts with a - we have to remove an entry
29  if (server[0]=='-')
30  {
31  fServerList.erase(server.substr(1));
32  CallbackServerRemove(server.substr(1));
33  continue;
34  }
35 
36  // If it starts with a + we have to add an entry
37  if (server[0]=='+')
38  server = server.substr(1);
39 
40  // Check if this server is already in the list.
41  // This should never happen if Dim works reliable
42  if (fServerList.insert(server).second)
43  CallbackServerAdd(server);
44  }
45 }
46 
48 {
49  if (evt.GetSize()==0)
50  return;
51 
52  // Get the name of the service
53  //const string svc = getInfo()->getName();
54 
55  // Get the server name from the service name
56  //const string server = svc.substr(0, svc.find_first_of('/'));
57  //const string service = svc.substr(svc.find_first_of('/')+1);
58 
59  msg = evt.GetString();
60  time = evt.GetTime();
61 
62  // Initialize the entry with an empty list
63  //if (msg[0]!='+' && msg[0]!='-')
64  // return;
65 
66  typedef char_separator<char> separator;
67  const tokenizer<separator> tok(msg, separator("\n"));
68 
69  for (auto it=tok.begin(); it!=tok.end(); it++)
70  {
71  string str = *it;
72 
73  if (str[0]=='-')
74  continue;
75 
76  if (str[0]=='+')
77  str = str.substr(1);
78 
79  const size_t last_pipe = str.find_last_of('|');
80 
81  // Get the type and compare it with fType
82  const string type = str.substr(last_pipe+1);
83  if (type=="RPC")
84  continue;
85 
86  //const bool iscmd = type=="CMD";
87  //if (type!=fType && fType!="*")
88  // continue;
89 
90  const size_t first_pipe = str.find_first_of('|');
91  const size_t first_slash = str.find_first_of('/');
92 
93  // Get format, name and command name
94  Service service;
95  service.server = str.substr(0, first_slash);
96  service.name = str.substr(0, first_pipe);
97  service.service = str.substr(first_slash+1, first_pipe-first_slash-1);
98  service.format = str.substr(first_pipe +1, last_pipe -first_pipe -1);
99  service.iscmd = type=="CMD";
100 
101  const auto v = find(fServiceList.begin(), fServiceList.end(), service.name);
102  if (v!=fServiceList.end())
103  continue;
104 
105  CallbackServiceAdd(service);
106  }
107 }
bool iscmd
Definition: Service.h:10
std::string format
Definition: Service.h:9
A general base-class describing events issues in a state machine.
Definition: EventImp.h:11
std::string server
Definition: Service.h:7
char str[80]
Definition: test_client.c:7
std::string service
Definition: Service.h:8
STL namespace.
std::string GetString() const
Definition: EventImp.cc:194
int type
virtual Time GetTime() const
Definition: EventImp.h:57
void HandlerServerImp(const EventImp &evt)
Definition: DimState.cc:6
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
std::string name
Definition: Service.h:6
void HandlerServiceListImp(const EventImp &evt)
Definition: DimState.cc:47
virtual size_t GetSize() const
Definition: EventImp.h:55