Belle II Software development
AbstractNSMCallback Class Referenceabstract
Inheritance diagram for AbstractNSMCallback:
Callback NSMCallback RCCallback DqmMasterCallback ERecoMasterCallback ERecoRunControlCallback EventServerCallback RFMasterCallback RFRunControlCallback RoiSenderCallback

Public Member Functions

 AbstractNSMCallback (int timeout)
 
int addDB (const DBObject &obj)
 
bool get (const NSMNode &node, const std::string &name, int &val, int timeout=5)
 
bool get (const NSMNode &node, const std::string &name, float &val, int timeout=5)
 
bool get (const NSMNode &node, const std::string &name, std::string &val, int timeout=5)
 
bool get (const NSMNode &node, const std::string &name, std::vector< int > &val, int timeout=5)
 
bool get (const NSMNode &node, const std::string &name, std::vector< float > &val, int timeout=5)
 
bool set (const NSMNode &node, const std::string &name, int val, int timeout=5)
 
bool set (const NSMNode &node, const std::string &name, float val, int timeout=5)
 
bool set (const NSMNode &node, const std::string &name, const std::string &val, int timeout=5)
 
bool set (const NSMNode &node, const std::string &name, const std::vector< int > &val, int timeout=5)
 
bool set (const NSMNode &node, const std::string &name, const std::vector< float > &val, int timeout=5)
 
bool get (const NSMNode &node, NSMVHandler *handler, int timeout=5)
 
bool get (const DBObject &obj)
 
bool get (const std::string &name, int &val)
 
bool get (const std::string &name, float &val)
 
bool get (const std::string &name, std::string &val)
 
bool get (const std::string &name, std::vector< int > &val)
 
bool get (const std::string &name, std::vector< float > &val)
 
bool set (const std::string &name, int val)
 
bool set (const std::string &name, float val)
 
bool set (const std::string &name, const std::string &val)
 
bool set (const std::string &name, const std::vector< int > &val)
 
bool set (const std::string &name, const std::vector< float > &val)
 
bool get (const std::string &node, const std::string &name, int &val)
 
bool get (const std::string &node, const std::string &name, float &val)
 
bool get (const std::string &node, const std::string &name, std::string &val)
 
bool get (const std::string &node, const std::string &name, std::vector< int > &val)
 
bool get (const std::string &node, const std::string &name, std::vector< float > &val)
 
bool set (const std::string &node, const std::string &name, int val)
 
bool set (const std::string &node, const std::string &name, float val)
 
bool set (const std::string &node, const std::string &name, const std::string &val)
 
bool set (const std::string &node, const std::string &name, const std::vector< int > &val)
 
bool set (const std::string &node, const std::string &name, const std::vector< float > &val)
 
int wait (double timeout=5)
 
NSMCommunicatorwait (const NSMNode &node, const NSMCommand &cmd, double timeout=5)
 
virtual void notify (const NSMVar &var)=0
 
bool try_wait ()
 
NSMNodegetNode ()
 
const NSMNodegetNode () const
 
void setNode (const NSMNode &node)
 
int getTimeout () const
 
void setTimeout (int timeout)
 
bool get (const NSMNode &node, NSMVar &var, int timeout=5)
 
bool set (const NSMNode &node, const NSMVar &var, int timeout=5)
 
int reset ()
 
int add (NSMVHandler *handler, bool overwrite=true, bool isdump=true)
 
void remove (const std::string &node, const std::string &name)
 
void remove (const std::string &name)
 
void remove (const DBObject &obj)
 
StringList & getHandlerNames ()
 
NSMVHandlerList & getHandlers ()
 
NSMVHandlergetHandler (const std::string &name)
 
NSMVHandlergetHandler (const std::string &node, const std::string &name)
 
void setUseGet (const std::string &name, bool use)
 
void setUseSet (const std::string &name, bool use)
 
void setRevision (int revision)
 
int getRevision () const
 

Protected Member Functions

virtual bool perform (NSMCommunicator &com)=0
 
void readVar (const NSMMessage &msg, NSMVar &var)
 

Private Member Functions

template<typename T >
bool get_t (const NSMNode &node, const std::string &name, T &val, int timeout, NSMVar::Type type=NSMVar::NONE, int len=0)
 
template<typename T >
bool get_t (const std::string &node, const std::string &name, T &val)
 
template<typename T >
bool set_t (const std::string &node, const std::string &name, const T &val)
 
NSMVHandlergetHandler_p (const std::string &node, const std::string &name)
 

Private Attributes

NSMNode m_node
 
int m_timeout
 
NSMNodeMapMap m_node_v_m
 
int m_revision
 
NSMVHandlerList m_handler
 
StringList m_hnames
 

Friends

class NSMCallback
 

Detailed Description

Definition at line 29 of file AbstractNSMCallback.h.

Constructor & Destructor Documentation

◆ AbstractNSMCallback()

AbstractNSMCallback ( int  timeout)

Definition at line 21 of file AbstractNSMCallback.cc.

22{
23 m_timeout = timeout;
24}

◆ ~AbstractNSMCallback()

virtual ~AbstractNSMCallback ( )
inlinevirtual

Definition at line 35 of file AbstractNSMCallback.h.

35{}

Member Function Documentation

◆ add()

int add ( NSMVHandler handler,
bool  overwrite = true,
bool  isdump = true 
)
inherited

Definition at line 25 of file Callback.cc.

26{
27 if (handler) {
28 std::string hname = handler->getNode() + "@" + handler->getName();
29 if (m_handler.find(hname) != m_handler.end()) {
30 NSMVHandler* handler_old = m_handler.find(hname)->second;
31 if (handler->useSet() && overwrite) {
32 handler->set(handler_old->get());
33 }
34 delete handler_old;
35 m_handler.erase(hname);
36 }
37 handler->setDumped(isdump);
38 m_handler.insert(std::pair<std::string, NSMVHandler*>(hname, handler));
39 m_hnames.push_back(hname);
40 return m_handler.size();
41 }
42 return 0;
43}

◆ addDB()

int addDB ( const DBObject obj)

Definition at line 26 of file AbstractNSMCallback.cc.

27{
28 DBObject::NameValueList list;
29 obj.search(list, "", true);
30 int id = 0;
31 for (DBObject::NameValueList::iterator it = list.begin();
32 it != list.end(); ++it) {
33 const std::string& name(it->name);
34 if (name.size() == 0 || name.at(0) == '$') continue;
35 switch (it->type) {
36 case DBField::BOOL:
37 id = Callback::add(new NSMVHandlerInt(name, true, true, (int) * ((bool*)it->buf)));
38 set(name, (int) * ((bool*)it->buf));
39 break;
40 case DBField::CHAR:
41 id = Callback::add(new NSMVHandlerInt(name, true, true, (int) * ((char*)it->buf)));
42 set(name, (int) * ((char*)it->buf));
43 break;
44 case DBField::SHORT:
45 id = Callback::add(new NSMVHandlerInt(name, true, true, (int) * ((short*)it->buf)));
46 set(name, (int) * ((short*)it->buf));
47 break;
48 case DBField::INT:
49 id = Callback::add(new NSMVHandlerInt(name, true, true, *((int*)it->buf)));
50 set(name, (int) * ((int*)it->buf));
51 break;
52 case DBField::LONG:
53 id = Callback::add(new NSMVHandlerInt(name, true, true, (int) * ((long long*)it->buf)));
54 set(name, (int) * ((long long*)it->buf));
55 break;
56 case DBField::FLOAT:
57 id = Callback::add(new NSMVHandlerFloat(name, true, true, *((float*)it->buf)));
58 set(name, * ((float*)it->buf));
59 break;
60 case DBField::DOUBLE:
61 id = Callback::add(new NSMVHandlerFloat(name, true, true, (float) * ((double*)it->buf)));
62 set(name, (float) * ((double*)it->buf));
63 break;
64 case DBField::TEXT:
65 id = Callback::add(new NSMVHandlerText(name, true, true, *((std::string*)it->buf)));
66 set(name, *((std::string*)it->buf));
67 break;
68 default:
69 break;
70 }
71 }
72 return id;
73}

◆ get() [1/18]

bool get ( const DBObject obj)

Definition at line 300 of file AbstractNSMCallback.cc.

301{
302 DBObject::NameValueList list;
303 obj.search(list);
304 for (DBObject::NameValueList::iterator it = list.begin();
305 it != list.end(); ++it) {
306 const std::string& name(it->name);
307 if (name.size() == 0 || name.at(0) == '$') continue;
308 int vi = 0;
309 float vf = 0;
310 std::string vs;
311 switch (it->type) {
312 case DBField::BOOL:
313 if (get(name, vi)) *((bool*)it->buf) = (bool)vi;
314 break;
315 case DBField::CHAR:
316 if (get(name, vi)) *((char*)it->buf) = (char)vi;
317 break;
318 case DBField::SHORT:
319 if (get(name, vi)) *((short*)it->buf) = (short)vi;
320 break;
321 case DBField::INT:
322 if (get(name, vi)) *((int*)it->buf) = (int)vi;
323 break;
324 case DBField::LONG:
325 if (get(name, vi)) *((long long*)it->buf) = vi;
326 break;
327 case DBField::FLOAT:
328 if (get(name, vf)) *((float*)it->buf) = vf;
329 break;
330 case DBField::DOUBLE:
331 if (get(name, vf)) *((double*)it->buf) = vf;
332 break;
333 case DBField::TEXT:
334 if (get(name, vs)) *((std::string*)it->buf) = vs;
335 break;
336 default:
337 break;
338 }
339 }
340 return true;
341}

◆ get() [2/18]

bool get ( const NSMNode node,
const std::string &  name,
float &  val,
int  timeout = 5 
)

Definition at line 246 of file AbstractNSMCallback.cc.

248{
249 return get_t(node, name, val, timeout, NSMVar::FLOAT, 0);
250}

◆ get() [3/18]

bool get ( const NSMNode node,
const std::string &  name,
int &  val,
int  timeout = 5 
)

Definition at line 240 of file AbstractNSMCallback.cc.

242{
243 return get_t(node, name, val, timeout, NSMVar::INT, 0);
244}

◆ get() [4/18]

bool get ( const NSMNode node,
const std::string &  name,
std::string &  val,
int  timeout = 5 
)

Definition at line 252 of file AbstractNSMCallback.cc.

254{
255 return get_t(node, name, val, timeout, NSMVar::TEXT, 1);
256}

◆ get() [5/18]

bool get ( const NSMNode node,
const std::string &  name,
std::vector< float > &  val,
int  timeout = 5 
)

Definition at line 264 of file AbstractNSMCallback.cc.

266{
267 return get_t(node, name, val, timeout, NSMVar::FLOAT, 1);
268}

◆ get() [6/18]

bool get ( const NSMNode node,
const std::string &  name,
std::vector< int > &  val,
int  timeout = 5 
)

Definition at line 258 of file AbstractNSMCallback.cc.

260{
261 return get_t(node, name, val, timeout, NSMVar::INT, 1);
262}

◆ get() [7/18]

bool get ( const NSMNode node,
NSMVar var,
int  timeout = 5 
)

Definition at line 176 of file AbstractNSMCallback.cc.

178{
179 if (node.getName().size() > 0) {
180 const std::string name = var.getName();
181 NSMCommunicator::send(NSMMessage(node, NSMCommand::VGET, name));
182 if (timeout < 0) return true;
183 double t0 = Time().get();
184 double t = t0;
185 double tout = timeout;
186 while (true) {
187 double t1 = (tout - (t - t0) > 0 ? tout - (t - t0) : 0);
188 NSMCommunicator& com(wait(NSMNode(), NSMCommand::UNKNOWN, t1));
189 NSMMessage msg = com.getMessage();
190 NSMCommand cmd(msg.getRequestName());
191 if (cmd == NSMCommand::VSET) {
192 if (msg.getLength() > 0 && msg.getData() != NULL &&
193 node.getName() == msg.getData() &&
194 var.getName() == (msg.getData() + msg.getParam(2) + 1)) {
195 readVar(msg, var);
196 return true;
197 }
198 } else if (cmd == NSMCommand::VGET || cmd == NSMCommand::VLISTGET ||
199 cmd == NSMCommand::OK || cmd == NSMCommand::ERROR || cmd == NSMCommand::FATAL) {
200 perform(com);
201 } else {
202 com.pushQueue(msg);
203 }
204 t = Time().get();
205 }
206 }
207 return false;
208}

◆ get() [8/18]

bool get ( const NSMNode node,
NSMVHandler handler,
int  timeout = 5 
)

Definition at line 141 of file AbstractNSMCallback.cc.

143{
144 if (handler && node.getName().size() > 0) {
145 NSMVar var(handler->get());
146 add(handler);
147 const std::string name = handler->getName();//var.getName();
148 NSMCommunicator::send(NSMMessage(node, NSMCommand::VGET, name));
149 if (timeout < 0) return true;
150 double t0 = Time().get();
151 double t = t0;
152 double tout = timeout;
153 while (true) {
154 double t1 = (tout - (t - t0) > 0 ? tout - (t - t0) : 0);
155 NSMCommunicator& com(wait(NSMNode(), NSMCommand::UNKNOWN, t1));
156 NSMMessage msg = com.getMessage();
157 NSMCommand cmd(msg.getRequestName());
158 if (cmd == NSMCommand::VSET) {
159 if (node.getName() == msg.getData() &&
160 var.getName() == (msg.getData() + msg.getParam(2) + 1)) {
161 readVar(msg, var);
162 return handler->handleSet(var);
163 }
164 } else if (cmd == NSMCommand::VGET || cmd == NSMCommand::VLISTGET ||
165 cmd == NSMCommand::OK || cmd == NSMCommand::ERROR || cmd == NSMCommand::FATAL) {
166 perform(com);
167 } else {
168 com.pushQueue(msg);
169 }
170 t = Time().get();
171 }
172 }
173 return false;
174}

◆ get() [9/18]

bool get ( const std::string &  name,
float &  val 
)
inline

Definition at line 52 of file AbstractNSMCallback.h.

52{ return get("", name, val); }

◆ get() [10/18]

bool get ( const std::string &  name,
int &  val 
)
inline

Definition at line 51 of file AbstractNSMCallback.h.

51{ return get("", name, val); }

◆ get() [11/18]

bool get ( const std::string &  name,
std::string &  val 
)
inline

Definition at line 53 of file AbstractNSMCallback.h.

53{ return get("", name, val); }

◆ get() [12/18]

bool get ( const std::string &  name,
std::vector< float > &  val 
)
inline

Definition at line 55 of file AbstractNSMCallback.h.

55{ return get("", name, val); }

◆ get() [13/18]

bool get ( const std::string &  name,
std::vector< int > &  val 
)
inline

Definition at line 54 of file AbstractNSMCallback.h.

54{ return get("", name, val); }

◆ get() [14/18]

bool get ( const std::string &  node,
const std::string &  name,
float &  val 
)
inline

Definition at line 62 of file AbstractNSMCallback.h.

62{ return get_t(node, name, val); }

◆ get() [15/18]

bool get ( const std::string &  node,
const std::string &  name,
int &  val 
)
inline

Definition at line 61 of file AbstractNSMCallback.h.

61{ return get_t(node, name, val); }

◆ get() [16/18]

bool get ( const std::string &  node,
const std::string &  name,
std::string &  val 
)
inline

Definition at line 63 of file AbstractNSMCallback.h.

63{ return get_t(node, name, val); }

◆ get() [17/18]

bool get ( const std::string &  node,
const std::string &  name,
std::vector< float > &  val 
)
inline

Definition at line 65 of file AbstractNSMCallback.h.

65{ return get_t(node, name, val); }

◆ get() [18/18]

bool get ( const std::string &  node,
const std::string &  name,
std::vector< int > &  val 
)
inline

Definition at line 64 of file AbstractNSMCallback.h.

64{ return get_t(node, name, val); }

◆ get_t() [1/2]

bool get_t ( const NSMNode node,
const std::string &  name,
T &  val,
int  timeout,
NSMVar::Type  type = NSMVar::NONE,
int  len = 0 
)
inlineprivate

Definition at line 99 of file AbstractNSMCallback.h.

101 {
102 NSMVar var(name);
103 var.setNode(node.getName());
104 if (get(node, var, timeout)) {
105 if (type == NSMVar::NONE ||
106 (type == var.getType() &&
107 ((len == 0 && var.getLength() == 0) ||
108 (len > 0 && var.getLength() > 0)))) {
109 var >> val;
110 return true;
111 }
112 }
113 return false;
114 }

◆ get_t() [2/2]

bool get_t ( const std::string &  node,
const std::string &  name,
T &  val 
)
inlineprivate

Definition at line 116 of file AbstractNSMCallback.h.

117 {
118 NSMVHandler* handler = getHandler_p(node, name);
119 if (handler) {
120 NSMVar var;
121 handler->handleGet(var);
122 var >> val;
123 return true;
124 }
125 return false;
126 }

◆ getHandler() [1/2]

NSMVHandler & getHandler ( const std::string &  name)
inlineinherited

Definition at line 42 of file Callback.h.

43 {
44 return getHandler("", name);
45 }

◆ getHandler() [2/2]

NSMVHandler & getHandler ( const std::string &  node,
const std::string &  name 
)
inherited

Definition at line 56 of file Callback.cc.

58{
59 NSMVHandler* p = getHandler_p(node, name);
60 if (p != NULL) return *p;
61 throw (std::out_of_range(StringUtil::form("no handler for %s:%s",
62 node.c_str(), name.c_str())));
63}

◆ getHandler_p()

NSMVHandler * getHandler_p ( const std::string &  node,
const std::string &  name 
)
privateinherited

Definition at line 65 of file Callback.cc.

66{
67 std::string hname = node + "@" + name;
68 if (m_handler.find(hname) != m_handler.end()) {
69 return m_handler.find(hname)->second;
70 }
71 hname = "@" + name;
72 if (m_handler.find(hname) != m_handler.end()) {
73 return m_handler.find(hname)->second;
74 }
75 return NULL;
76}

◆ getHandlerNames()

StringList & getHandlerNames ( )
inlineinherited

Definition at line 40 of file Callback.h.

40{ return m_hnames; }

◆ getHandlers()

NSMVHandlerList & getHandlers ( )
inlineinherited

Definition at line 41 of file Callback.h.

41{ return m_handler; }

◆ getNode() [1/2]

NSMNode & getNode ( )
inline

Definition at line 78 of file AbstractNSMCallback.h.

78{ return m_node; }

◆ getNode() [2/2]

const NSMNode & getNode ( ) const
inline

Definition at line 79 of file AbstractNSMCallback.h.

79{ return m_node; }

◆ getRevision()

int getRevision ( ) const
inlineinherited

Definition at line 59 of file Callback.h.

59{ return m_revision; }

◆ getTimeout()

int getTimeout ( ) const
inline

Definition at line 81 of file AbstractNSMCallback.h.

81{ return m_timeout; }

◆ notify()

virtual void notify ( const NSMVar var)
pure virtual

Implements Callback.

◆ readVar()

void readVar ( const NSMMessage msg,
NSMVar var 
)
protected

Definition at line 129 of file AbstractNSMCallback.cc.

130{
131 const int* pars = msg.getParams();
132 const char* node = msg.getData();
133 const char* name = (msg.getData() + pars[2] + 1);
134 const char* value = (msg.getData() + pars[2] + 1 + pars[3] + 1);
135 var = NSMVar(name, (NSMVar::Type)pars[0], pars[1], value);
136 var.setNode(node);
137 var.setId(pars[4]);
138 var.setDate(pars[5]);
139}

◆ remove() [1/3]

void remove ( const DBObject obj)
inherited

Definition at line 78 of file Callback.cc.

79{
80 DBObject::NameValueList list;
81 obj.search(list, "", true);
82 for (DBObject::NameValueList::iterator it = list.begin();
83 it != list.end(); ++it) {
84 const std::string& name(it->name);
85 if (name.size() == 0 || name.at(0) == '$') continue;
86 switch (it->type) {
87 case DBField::OBJECT:
88 break;
89 default:
90 remove(name);
91 break;
92 }
93 }
94}

◆ remove() [2/3]

void remove ( const std::string &  name)
inlineinherited

Definition at line 38 of file Callback.h.

38{ remove("", name); }

◆ remove() [3/3]

void remove ( const std::string &  node,
const std::string &  name 
)
inherited

Definition at line 45 of file Callback.cc.

46{
47 std::string hname = node + "@" + node;
48 if (m_handler.find(hname) != m_handler.end()) {
49 NSMVHandler* handler_old = m_handler.find(hname)->second;
50 delete handler_old;
51 m_handler.erase(hname);
52 return;
53 }
54}

◆ reset()

int reset ( )
inherited

Definition at line 14 of file Callback.cc.

15{
16 for (NSMVHandlerList::iterator it = m_handler.begin();
17 it != m_handler.end(); ++it) {
18 if (it->second != NULL) delete it->second;
19 }
20 m_handler = NSMVHandlerList();
21 m_hnames = StringList();
22 return ++m_revision;
23}

◆ set() [1/16]

bool set ( const NSMNode node,
const NSMVar var,
int  timeout = 5 
)

Definition at line 210 of file AbstractNSMCallback.cc.

212{
213 if (node.getName().size() > 0) {
214 NSMCommunicator::send(NSMMessage(node, var));
215 if (timeout < 0) return true;
216 double t0 = Time().get();
217 double t = t0;
218 double tout = timeout;
219 while (true) {
220 double t1 = (tout - (t - t0) > 0 ? tout - (t - t0) : 0);
221 NSMCommunicator& com(wait(node, NSMCommand::VREPLY, t1));
222 NSMMessage msg(com.getMessage());
223 NSMCommand cmd(msg.getRequestName());
224 if (cmd == NSMCommand::VREPLY && var.getName() == msg.getData()) {
225 bool ret = msg.getParam(0) > 0;
226 perform(com);
227 return ret;
228 } else if (cmd == NSMCommand::VGET || cmd == NSMCommand::VLISTGET ||
229 cmd == NSMCommand::OK || cmd == NSMCommand::ERROR || cmd == NSMCommand::FATAL) {
230 perform(com);
231 } else {
232 com.pushQueue(msg);
233 }
234 t = Time().get();
235 }
236 }
237 return false;
238}

◆ set() [2/16]

bool set ( const NSMNode node,
const std::string &  name,
const std::string &  val,
int  timeout = 5 
)

Definition at line 282 of file AbstractNSMCallback.cc.

284{
285 return set(node, NSMVar(name, val), timeout);
286}

◆ set() [3/16]

bool set ( const NSMNode node,
const std::string &  name,
const std::vector< float > &  val,
int  timeout = 5 
)

Definition at line 294 of file AbstractNSMCallback.cc.

296{
297 return set(node, NSMVar(name, val), timeout);
298}

◆ set() [4/16]

bool set ( const NSMNode node,
const std::string &  name,
const std::vector< int > &  val,
int  timeout = 5 
)

Definition at line 288 of file AbstractNSMCallback.cc.

290{
291 return set(node, NSMVar(name, val), timeout);
292}

◆ set() [5/16]

bool set ( const NSMNode node,
const std::string &  name,
float  val,
int  timeout = 5 
)

Definition at line 276 of file AbstractNSMCallback.cc.

278{
279 return set(node, NSMVar(name, val), timeout);
280}

◆ set() [6/16]

bool set ( const NSMNode node,
const std::string &  name,
int  val,
int  timeout = 5 
)

Definition at line 270 of file AbstractNSMCallback.cc.

272{
273 return set(node, NSMVar(name, val), timeout);
274}

◆ set() [7/16]

bool set ( const std::string &  name,
const std::string &  val 
)
inline

Definition at line 58 of file AbstractNSMCallback.h.

58{ return set("", name, val); }

◆ set() [8/16]

bool set ( const std::string &  name,
const std::vector< float > &  val 
)
inline

Definition at line 60 of file AbstractNSMCallback.h.

60{ return set("", name, val); }

◆ set() [9/16]

bool set ( const std::string &  name,
const std::vector< int > &  val 
)
inline

Definition at line 59 of file AbstractNSMCallback.h.

59{ return set("", name, val); }

◆ set() [10/16]

bool set ( const std::string &  name,
float  val 
)
inline

Definition at line 57 of file AbstractNSMCallback.h.

57{ return set("", name, val); }

◆ set() [11/16]

bool set ( const std::string &  name,
int  val 
)
inline

Definition at line 56 of file AbstractNSMCallback.h.

56{ return set("", name, val); }

◆ set() [12/16]

bool set ( const std::string &  node,
const std::string &  name,
const std::string &  val 
)
inline

Definition at line 68 of file AbstractNSMCallback.h.

68{ return set_t(node, name, val); }

◆ set() [13/16]

bool set ( const std::string &  node,
const std::string &  name,
const std::vector< float > &  val 
)
inline

Definition at line 70 of file AbstractNSMCallback.h.

70{ return set_t(node, name, val); }

◆ set() [14/16]

bool set ( const std::string &  node,
const std::string &  name,
const std::vector< int > &  val 
)
inline

Definition at line 69 of file AbstractNSMCallback.h.

69{ return set_t(node, name, val); }

◆ set() [15/16]

bool set ( const std::string &  node,
const std::string &  name,
float  val 
)
inline

Definition at line 67 of file AbstractNSMCallback.h.

67{ return set_t(node, name, val); }

◆ set() [16/16]

bool set ( const std::string &  node,
const std::string &  name,
int  val 
)
inline

Definition at line 66 of file AbstractNSMCallback.h.

66{ return set_t(node, name, val); }

◆ set_t()

bool set_t ( const std::string &  node,
const std::string &  name,
const T &  val 
)
inlineprivate

Definition at line 128 of file AbstractNSMCallback.h.

129 {
130 NSMVHandler* handler = getHandler_p(node, name);
131 if (handler) {
132 handler->set(val);
133 if (node.size() == 0) {
134 notify(handler->get());
135 }
136 return true;
137 }
138 return false;
139 }

◆ setNode()

void setNode ( const NSMNode node)
inline

Definition at line 80 of file AbstractNSMCallback.h.

80{ m_node = node; }

◆ setRevision()

void setRevision ( int  revision)
inlineinherited

Definition at line 58 of file Callback.h.

58{ m_revision = revision; }

◆ setTimeout()

void setTimeout ( int  timeout)
inline

Definition at line 82 of file AbstractNSMCallback.h.

82{ m_timeout = timeout; }

◆ setUseGet()

void setUseGet ( const std::string &  name,
bool  use 
)
inlineinherited

Definition at line 48 of file Callback.h.

49 {
50 getHandler(name).setUseGet(use);
51 }

◆ setUseSet()

void setUseSet ( const std::string &  name,
bool  use 
)
inlineinherited

Definition at line 52 of file Callback.h.

53 {
54 getHandler(name).setUseSet(use);
55 }

◆ try_wait()

bool try_wait ( )

Definition at line 119 of file AbstractNSMCallback.cc.

120{
121 try {
122 perform(wait(NSMNode(), NSMCommand::UNKNOWN, 0));
123 } catch (const std::exception& e) {
124 return false;
125 }
126 return true;
127}

◆ wait() [1/2]

NSMCommunicator & wait ( const NSMNode node,
const NSMCommand cmd,
double  timeout = 5 
)

Definition at line 75 of file AbstractNSMCallback.cc.

78{
79 double t0 = Time().get();
80 double t = t0;
81 while (true) {
82 double t1 = (timeout - (t - t0) > 0 ? timeout - (t - t0) : 0);
83 NSMCommunicator& com(NSMCommunicator::select(t1));
84 NSMMessage msg = com.getMessage();
85 const std::string reqname = msg.getRequestName();
86 if ((cmd == NSMCommand::UNKNOWN || cmd == reqname) &&
87 (node.getName().size() == 0 || msg.getNodeName() == node.getName())) {
88 return com;
89 }
90 com.pushQueue(msg);
91 t = Time().get();
92 }
93}

◆ wait() [2/2]

int wait ( double  timeout = 5)

Definition at line 95 of file AbstractNSMCallback.cc.

96{
97 double t0 = Time().get();
98 double t = t0;
99 int count = 0;
100 try {
101 while (true) {
102 double t1 = (timeout - (t - t0) > 0 ? timeout - (t - t0) : 0);
103 if (t1 == 0) break;
104 NSMCommunicator& com(NSMCommunicator::select(t1));
105 NSMMessage msg = com.getMessage();
106 NSMCommand cmd(msg.getRequestName());
107 if (cmd == NSMCommand::VGET || cmd == NSMCommand::VLISTGET) {
108 perform(com);
109 } else {
110 com.pushQueue(msg);
111 }
112 t = Time().get();
113 }
114 } catch (const TimeoutException& e) {
115 }
116 return count;
117}

Friends And Related Function Documentation

◆ NSMCallback

friend class NSMCallback
friend

Definition at line 31 of file AbstractNSMCallback.h.

Member Data Documentation

◆ m_handler

NSMVHandlerList m_handler
privateinherited

Definition at line 66 of file Callback.h.

◆ m_hnames

StringList m_hnames
privateinherited

Definition at line 67 of file Callback.h.

◆ m_node

NSMNode m_node
private

Definition at line 89 of file AbstractNSMCallback.h.

◆ m_node_v_m

NSMNodeMapMap m_node_v_m
private

Definition at line 91 of file AbstractNSMCallback.h.

◆ m_revision

int m_revision
privateinherited

Definition at line 65 of file Callback.h.

◆ m_timeout

int m_timeout
private

Definition at line 90 of file AbstractNSMCallback.h.


The documentation for this class was generated from the following files: