YARP
Yet Another Robot Platform
NameServiceOnTriples.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #include <cstdlib>
11 
12 #include <yarp/os/Vocab.h>
13 #include <yarp/os/NestedContact.h>
14 #include <yarp/os/Network.h>
15 #include <yarp/os/Time.h>
16 #include <yarp/os/SystemClock.h>
20 
21 using namespace yarp::os;
22 using namespace yarp::serversql::impl;
23 using namespace std;
24 
25 namespace {
26 YARP_SERVERSQL_LOG_COMPONENT(NAMESERVICEONTRIPLES, "yarp.serversql.impl.NameServiceOnTriples")
27 } // namespace
28 
29 
30 Contact NameServiceOnTriples::query(const std::string& portName,
31  NameTripleState& act,
32  const std::string& prefix,
33  bool nested)
34 {
35  if (!nested) {
36  lock();
37  }
38  Triple t;
39  t.setNameValue("port",portName.c_str());
40  int result = act.mem.find(t, nullptr);
41  TripleContext context;
42  context.setRid(result);
43  if (result!=-1) {
44  std::string host;
45  if (!std::string(prefix).empty()) {
46  printf("LOOKING AT IPS FOR %s\n", prefix.c_str());
47  t.setNameValue("ips","*");
48  list<Triple> lst = act.mem.query(t,&context);
49  for (auto& it : lst) {
50  printf("LOOKING AT IPS %s\n", it.value.c_str());
51  if (it.value.find(prefix)==0) {
52  host = it.value;
53  break;
54  }
55  }
56  }
57  if (host.empty()) {
58  t.setNameValue("host","*");
59  list<Triple> lst = act.mem.query(t,&context);
60  if (!lst.empty()) {
61  host = lst.begin()->value;
62  }
63  }
64  if (host.empty()) {
65  host = "localhost";
66  }
67  t.setNameValue("socket","*");
68  list<Triple> lst = act.mem.query(t,&context);
69  int sock = 10000;
70  if (!lst.empty()) {
71  sock = atoi(lst.begin()->value.c_str());
72  }
73  t.setNameValue("carrier","*");
74  std::string carrier = "tcp";
75  lst = act.mem.query(t,&context);
76  if (!lst.empty()) {
77  carrier = lst.begin()->value;
78  }
79  t.setNameValue("type","*");
80  std::string typ = "*";
81  lst = act.mem.query(t,&context);
82  if (!lst.empty()) {
83  typ = lst.begin()->value;
84  }
85  if (!nested) {
86  unlock();
87  }
88  Contact result = Contact(portName, carrier, host, sock);
89  if (!typ.empty() && typ!="*") {
90  NestedContact nc;
91  nc.fromString(result.getName());
92  nc.setTypeName(typ);
93  result.setNestedContact(nc);
94  }
95  return result;
96  }
97  if (!nested) {
98  unlock();
99  }
100  if (delegate && !nested) {
101  return delegate->queryName(portName);
102  }
103  return Contact();
104 }
105 
106 
107 yarp::os::Contact NameServiceOnTriples::query(const std::string& port)
108 {
109  Contact check = Contact::fromString(port);
110  if (!check.getHost().empty()) {
111  return check;
112  }
113  Bottle cmd;
114  Bottle reply;
115  Bottle event;
116  Contact remote;
117  TripleSource& mem = *db;
118  NameTripleState act(cmd,reply,event,remote,mem);
119  return query(port,act,"");
120 }
121 
122 
123 bool NameServiceOnTriples::cmdQuery(NameTripleState& act, bool nested)
124 {
125  std::string port = act.cmd.get(1).asString();
126 
127  ParseName parser;
128  parser.apply(port);
129  port = parser.getPortName();
130 
131  /*
132  // port names may be prefixed - sort that out
133  std::string base = port;
134  std::string pat = "";
135  if (base.find("/net=") == 0 || base.find("/NET=") == 0) {
136  int patStart = 5;
137  int patEnd = base.find('/',patStart);
138  if (patEnd>=patStart) {
139  pat = base.substr(patStart,patEnd-patStart);
140  base = base.substr(patEnd);
141  }
142  port = base;
143  }
144  */
145 
146  if (act.reply.size()==0 && !act.bottleMode) {
147  act.reply.addString("old");
148  }
149  Bottle& q=(act.bottleMode&&!act.nestedMode)?
150  act.reply :
151  act.reply.addList();
152  Contact c = query(port, act, parser.getNetworkChoice(), nested);
153  std::string host = c.getHost();
154  std::string carrier = c.getCarrier();
155  int sock = c.getPort();
156  if (c.isValid()) {
157  if (!act.bottleMode) {
158  q.addString("registration");
159  q.addString("name");
160  q.addString(port);
161  q.addString("ip");
162  q.addString(host);
163  q.addString("port");
164  q.addInt32(sock);
165  q.addString("type");
166  q.addString(carrier);
167  } else {
168  Bottle bname;
169  bname.addString("name");
170  bname.addString(port);
171  Bottle bip;
172  bip.addString("ip");
173  bip.addString(host);
174  Bottle bnum;
175  bnum.addString("port_number");
176  bnum.addInt32(sock);
177  Bottle bcarrier;
178  bcarrier.addString("carrier");
179  bcarrier.addString(carrier);
180  q.addString("port");
181  q.addList() = bname;
182  q.addList() = bip;
183  q.addList() = bnum;
184  q.addList() = bcarrier;
185  }
186  } else {
187  if (act.bottleMode) {
188  Bottle bstate;
189  bstate.addString("error");
190  bstate.addInt32(-2);
191  bstate.addString("port not known");
192  q.addString("port");
193  q.addList() = bstate;
194  }
195  }
196  return true;
197 }
198 
199 bool NameServiceOnTriples::cmdRegister(NameTripleState& act)
200 {
201  std::string port = act.cmd.get(1).asString();
202 
203  lock();
204  Triple t;
205  t.setNameValue("port",port.c_str());
206  int result = act.mem.find(t, nullptr);
207  unlock();
208 
209  if (result!=-1) {
210  // Hmm, we already have a registration.
211  // This could be fine - maybe program crashed or was abruptly
212  // terminated. Classically, that is what YARP would assume.
213  // Now, let us try checking instead to see if there is a port
214  // alive at the registered address. Note that this can lead
215  // to delays...
216 #if 0
217  Contact c = query(port.c_str());
218  if (c.isValid()) {
219  if (gonePublic) {
220  printf(" ? checking prior registration, to avoid accidental collision\n");
221  Bottle cmd("[ver]"), reply;
222  double timeout = 3.0;
223  double pre = SystemClock::nowSystem();
224  bool ok = Network::write(c,cmd,reply,true,true,timeout);
225  double post = SystemClock::nowSystem();
226  if (post-pre>timeout-1) {
227  ok = false;
228  }
229  if (ok) {
230  printf(" ? prior registration seems to be live! Denying new registration.\n");
231  /*
232  printf("Got a live one! %s - said %s\n",
233  port.c_str(),
234  reply.toString().c_str());
235  */
236  // oops! there is a live port!
237  // give back a blank query
238  act.cmd.fromString("query");
239  return cmdQuery(act);
240  } else {
241  printf(" ! prior registration seems to be no longer valid, good!\n");
242  }
243  }
244  }
245 #endif
246  cmdUnregister(act);
247  act.reply.clear();
248  }
249 
250  act.reply.addString("old");
251 
252  size_t at = 2;
253  int sock = -1;
254  std::string carrier = "...";
255  std::string machine = "...";
256  std::string typ = "*";
257  if (act.cmd.size()>at) {
258  carrier = act.cmd.get(at).asString();
259  at++;
260  }
261  if (carrier=="...") {
262  carrier = "tcp";
263  }
264  if (act.cmd.size()>at) {
265  machine = act.cmd.get(at).asString();
266  at++;
267  }
268  if (machine == "...") {
269  if (carrier=="topic") {
270  machine = serverContact.getHost();
271  } else if (carrier!="mcast") {
272  std::string remote = act.remote.getHost();
273  if (remote.empty() || remote == "...") {
274  //fprintf(stderr,"Not detecting real remote machine name, guessing local\n");
275  machine = "localhost";
276  } else {
277  machine = remote;
278  }
279  }
280  }
281  if (act.cmd.size()>at) {
282  sock = act.cmd.get(at).asInt32();
283  at++;
284  } else {
285  if (carrier=="topic") {
286  sock = serverContact.getPort();
287  }
288  }
289  if (act.cmd.size()>at) {
290  typ = act.cmd.get(at).asString();
291  at++;
292  }
293  lock();
294  if (port=="..." || (port.length()>0 && port[0]=='=')) {
295  Contact c(port, carrier, machine, sock);
296  c = alloc->completePortName(c);
297  if (port =="...") {
298  port = c.getName();
299  } else {
300  port = c.getName() + port;
301  }
302  }
303  t.setNameValue("port",port.c_str());
304  act.mem.remove_query(t, nullptr);
305  act.mem.insert(t, nullptr);
306  result = act.mem.find(t, nullptr);
307  TripleContext context;
308  context.setRid(result);
309  t.setNameValue("carrier",carrier.c_str());
310  act.mem.update(t,&context);
311  char buf[100];
312  Contact c(port, carrier, machine, sock);
313  c = alloc->completeSocket(c);
314  sock = c.getPort();
315  machine = c.getHost();
316  t.setNameValue("host",machine.c_str());
317  act.mem.update(t,&context);
318  sprintf(buf,"%d",sock);
319  t.setNameValue("socket",buf);
320  act.mem.update(t,&context);
321  if (typ!="*") {
322  t.setNameValue("type",typ.c_str());
323  act.mem.update(t,&context);
324  }
325  // now, query to report that it worked
326  act.mem.reset();
327  act.cmd.clear();
328  act.cmd.addString("query");
329  act.cmd.addString(port);
330 
331  if (carrier!="mcast") {
332  Bottle& event = act.event.addList();
333  event.addVocab(Vocab::encode("add"));
334  event.addString(port);
335  }
336  unlock();
337 
338  return cmdQuery(act);
339 }
340 
341 
342 bool NameServiceOnTriples::announce(const std::string& name, int activity)
343 {
344  if (subscriber != nullptr && gonePublic) {
345  subscriber->welcome(name,activity);
346  }
347  return true;
348 }
349 
350 bool NameServiceOnTriples::cmdUnregister(NameTripleState& act)
351 {
352  std::string port = act.cmd.get(1).asString();
353  //printf(" - unregister %s\n", port.c_str());
354  announce(port,-1);
355  lock();
356  Contact contact = query(port,act,"",true);
357  alloc->freePortResources(contact);
358  act.reply.addString("old");
359  Triple t;
360  t.setNameValue("port",port.c_str());
361  int result = act.mem.find(t, nullptr);
362  TripleContext context;
363  context.setRid(result);
364  if (result!=-1) {
365  t.setNameValue("owns","*");
366  list<Triple> lst = act.mem.query(t,&context);
367  unlock();
368  for (auto& it : lst) {
369  act.cmd.clear();
370  act.cmd.addString("unregister");
371  act.cmd.addString(it.value.c_str());
372  cmdUnregister(act);
373  }
374  lock();
375  t.setNsNameValue("*","*","*");
376  act.mem.remove_query(t,&context);
377 
378  t.setNameValue("port",port.c_str());
379  act.mem.remove_query(t, nullptr);
380  // now, query to report that there is nothing there
381 
382  if (contact.getCarrier()!="mcast") {
383  Bottle& event = act.event.addList();
384  event.addVocab(Vocab::encode("del"));
385  event.addString(port);
386  }
387  }
388 
389  act.mem.reset();
390  unlock();
391 
392  return cmdQuery(act);
393 }
394 
395 bool NameServiceOnTriples::cmdListRunners(NameTripleState& act)
396 { // this is a combination of cmdList and cmdCheck codes
397  if (!act.bottleMode)
398  {
399  act.reply.addString("old");
400  } else
401  {
402  act.reply.addString("ports");
403  }
404  lock();
405  Triple t;
406  t.setNameValue("port","*");
407 
408  // obtain all ports names
409  list<Triple> lst = act.mem.query(t, nullptr);
410  act.nestedMode = true;
411 
412  for (auto& it : lst)
413  { // check yarprun property for each port
414  std::string port = it.value;
415  act.mem.reset();
416 
417  Triple t;
418  t.setNameValue("port",port.c_str());
419  int rid = act.mem.find(t, nullptr);
420  if (rid == -1) {
421  unlock();
422  return false;
423  }
424 
425  // find all triples with yarprun = true for the specified RID (at most one)
426  TripleContext context;
427  context.setRid(rid);
428  t.setNameValue("yarprun","true");
429  list<Triple> lst = act.mem.query(t,&context);
430 
431  if (!lst.empty())
432  { // if the port is a runner, do a classic query to build the reply with complete information about the port
433  act.cmd.clear();
434  act.cmd.addString("query");
435  act.cmd.addString(port);
436  act.mem.reset();
437  cmdQuery(act, true);
438  }
439  }
440  unlock();
441  return true;
442 }
443 
444 bool NameServiceOnTriples::cmdList(NameTripleState& act)
445 {
446  if (!act.bottleMode) {
447  act.reply.addString("old");
448  } else {
449  act.reply.addString("ports");
450  }
451  lock();
452  Triple t;
453  t.setNameValue("port","*");
454  std::string prefix;
455  if (act.cmd.size()>1) {
456  prefix = act.cmd.get(1).asString();
457  }
458  list<Triple> lst = act.mem.query(t, nullptr);
459  act.nestedMode = true;
460  for (auto& it : lst) {
461  if (prefix.empty()) {
462  act.cmd.clear();
463  act.cmd.addString("query");
464  act.cmd.addString(it.value.c_str());
465  act.mem.reset();
466  cmdQuery(act,true);
467  } else {
468  std::string iname = it.value;
469  if (iname.find(prefix)==0) {
470  if (iname==prefix || iname[prefix.length()]=='/' ||
471  prefix[prefix.length()-1]=='/') {
472  act.cmd.clear();
473  act.cmd.addString("query");
474  act.cmd.addString(iname);
475  act.mem.reset();
476  cmdQuery(act,true);
477  }
478  }
479  }
480  }
481  unlock();
482  return true;
483 }
484 
485 
486 bool NameServiceOnTriples::cmdSet(NameTripleState& act)
487 {
488  lock();
489  if (!act.bottleMode) {
490  act.reply.addString("old");
491  }
492  std::string port = act.cmd.get(1).asString();
493  std::string key = act.cmd.get(2).toString();
494  int at = 3;
495  int n = act.cmd.size() - at;
496  Triple t;
497  t.setNameValue("port", port.c_str());
498  int result = act.mem.find(t, nullptr);
499  if (result==-1) {
500  unlock();
501  return false;
502  }
503  TripleContext context;
504  context.setRid(result);
505  t.setNameValue(key.c_str(),"*");
506  act.mem.remove_query(t,&context);
507  for (int i=0; i<n; i++) {
508  t.setNameValue(key.c_str(),act.cmd.get(at).toString().c_str());
509  at++;
510  act.mem.insert(t,&context);
511  }
512  act.mem.reset();
513  act.cmd.clear();
514  act.cmd.addString("get");
515  act.cmd.addString(port);
516  act.cmd.addString(key);
517  unlock();
518  return cmdGet(act);
519 }
520 
521 
522 bool NameServiceOnTriples::cmdGet(NameTripleState& act)
523 {
524  lock();
525  if (!act.bottleMode) {
526  if (act.reply.size()==0) {
527  act.reply.addString("old");
528  }
529  }
530  std::string port = act.cmd.get(1).asString();
531  std::string key = act.cmd.get(2).toString();
532  Triple t;
533  t.setNameValue("port",port.c_str());
534  int result = act.mem.find(t, nullptr);
535  if (result==-1) {
536  unlock();
537  return false;
538  }
539  TripleContext context;
540  context.setRid(result);
541  t.setNameValue(key.c_str(),"*");
542  list<Triple> lst = act.mem.query(t,&context);
543  Bottle& q = (act.bottleMode?act.reply:act.reply.addList());
544  if (!act.bottleMode) {
545  q.addString("port");
546  q.addString(port);
547  q.addString("property");
548  q.addString(key);
549  q.addString("=");
550  for (auto& it : lst) {
551  q.addString(it.value.c_str());
552  }
553  } else {
554  for (auto& it : lst) {
555  Value v;
556  v.fromString(it.value.c_str());
557  q.add(v);
558  }
559  }
560  unlock();
561  return true;
562 }
563 
564 
565 bool NameServiceOnTriples::cmdCheck(NameTripleState& act)
566 {
567  lock();
568  if (act.reply.size()==0) {
569  act.reply.addString("old");
570  }
571  std::string port = act.cmd.get(1).asString();
572  std::string key = act.cmd.get(2).toString();
573  std::string val = act.cmd.get(3).toString();
574  Triple t;
575  t.setNameValue("port",port.c_str());
576  int result = act.mem.find(t, nullptr);
577  if (result==-1) {
578  unlock();
579  return false;
580  }
581  TripleContext context;
582  context.setRid(result);
583  t.setNameValue(key.c_str(),"*");
584  list<Triple> lst = act.mem.query(t,&context);
585  Bottle& q = act.reply.addList();
586  q.addString("port");
587  q.addString(port);
588  q.addString("property");
589  q.addString(key);
590  q.addString("value");
591  q.addString(val);
592  q.addString("present");
593  std::string present = "false";
594  for (auto& it : lst) {
595  if (val == it.value) {
596  present = "true";
597  }
598  }
599  q.addString(present);
600  unlock();
601  return true;
602 }
603 
604 
605 bool NameServiceOnTriples::cmdRoute(NameTripleState& act)
606 {
607  if (act.reply.size()==0) {
608  act.reply.addString("old");
609  }
610  std::string port1 = act.cmd.get(1).asString();
611  std::string port2 = act.cmd.get(2).asString();
612  Bottle& q = act.reply.addList();
613  q.addString("port");
614  q.addString(port1);
615  q.addString("route");
616  q.addString(port2);
617  q.addString("=");
618  q.addString(std::string("tcp:/") + port2);
619  return true;
620 }
621 
622 bool NameServiceOnTriples::cmdGc(NameTripleState& act)
623 {
624  act.reply.addString("old");
625  Bottle& q = act.reply.addList();
626  // nothing needed
627  q.addString("garbage collection done.");
628  return true;
629 }
630 
631 
632 bool NameServiceOnTriples::cmdHelp(NameTripleState& act)
633 {
634  Bottle& bot = act.reply;
635  if (!act.bottleMode) {
636  bot.addString("old");
637  bot.addString("Here are some ways to use the name server:");
638  }
639  bot.addString("+ help");
640  bot.addString("+ list [$prefix]");
641  bot.addString("+ register $portname");
642  bot.addString("+ register $portname $carrier $ipAddress $portNumber");
643  bot.addString(" (if you want a field set automatically, write '...')");
644  bot.addString("+ unregister $portname");
645  bot.addString("+ query $portname");
646  bot.addString("+ set $portname $property $value");
647  bot.addString("+ get $portname $property");
648  bot.addString("+ check $portname $property");
649  bot.addString("+ route $port1 $port2");
650  bot.addString("+ runners");
651  bot.addString(" (to get a list of the yarprun ports)");
652  return true;
653 }
654 
655 bool NameServiceOnTriples::apply(yarp::os::Bottle& cmd,
656  yarp::os::Bottle& reply,
657  yarp::os::Bottle& event,
658  const yarp::os::Contact& remote)
659 {
660  std::string key = cmd.get(0).toString();
661  std::string prefix = " * ";
662 
663  access.wait();
664  if (key=="register") {
665  lastRegister = cmd.get(1).asString();
666  } else if (key=="set") {
667  if (cmd.get(1).asString()==lastRegister) {
668  prefix = " + ";
669  }
670  } else {
671  lastRegister = "";
672  }
673  if (!silent) {
674  yCInfo(NAMESERVICEONTRIPLES, "%s%s", prefix.c_str(), cmd.toString().c_str());
675  }
676  access.post();
677 
678  TripleSource& mem = *db;
679  //mem.begin();
680  mem.reset();
681  reply.clear();
682  NameTripleState act(cmd,reply,event,remote,mem);
683 
684  if (cmd.check("format")) {
685  if (cmd.find("format").asString()=="json") {
686  act.bottleMode = true;
687  }
688  }
689 
690  if (key == "NAME_SERVER") {
691  cmd = cmd.tail();
692  key = cmd.get(0).asString();
693  }
694  if (key == "bot") {
695  act.bottleMode = true;
696  cmd = cmd.tail();
697  key = cmd.get(0).asString();
698  }
699 
700  if (key=="register") {
701  return cmdRegister(act);
702  }
703  if (key=="unregister") {
704  return cmdUnregister(act);
705  }
706  if (key=="query") {
707  return cmdQuery(act);
708  }
709  if (key=="list") {
710  return cmdList(act);
711  }
712  if (key=="runners") {
713  return cmdListRunners(act);
714  }
715  if (key=="set") {
716  return cmdSet(act);
717  }
718  if (key=="get") {
719  return cmdGet(act);
720  }
721  if (key=="check") {
722  return cmdCheck(act);
723  }
724  if (key=="route") {
725  return cmdRoute(act);
726  }
727  if (key=="gc") {
728  return cmdGc(act);
729  }
730  if (key=="help") {
731  return cmdHelp(act);
732  }
733 
734  // not understood
735  act.reply.addString("old");
736 
737  //mem.end();
738 
739  return true;
740 }
741 
742 
743 
744 void NameServiceOnTriples::lock()
745 {
746  mutex.lock();
747  db->begin(nullptr);
748 }
749 
750 void NameServiceOnTriples::unlock()
751 {
752  db->end(nullptr);
753  mutex.unlock();
754 }
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
yarp::serversql::impl::TripleSource::reset
virtual void reset()
Definition: TripleSource.h:53
yarp::os::Bottle::toString
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition: Bottle.cpp:214
SystemClock.h
yarp::os::Bottle::clear
void clear()
Empties the bottle of any objects it contains.
Definition: Bottle.cpp:124
Network.h
YARP_SERVERSQL_LOG_COMPONENT
#define YARP_SERVERSQL_LOG_COMPONENT(name, name_string)
Definition: LogComponent.h:37
yarp::serversql::impl::NameTripleState::mem
TripleSource & mem
Definition: NameServiceOnTriples.h:36
yarp::os::NestedContact
A placeholder for rich contact information.
Definition: NestedContact.h:27
yarp::os::NestedContact::setTypeName
void setTypeName(const std::string &nWireType)
Definition: NestedContact.cpp:164
yarp::os::Bottle::size
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:254
ParseName.h
t
float t
Definition: FfmpegWriter.cpp:74
yarp::serversql::impl::TripleContext
Side information for controlling access to triples.
Definition: TripleSource.h:27
yarp::serversql::impl::Triple
The basic unit of data the name server works with.
Definition: Triple.h:28
yarp::os::Contact::getName
std::string getName() const
Get the name associated with this Contact.
Definition: Contact.cpp:208
yarp::os::NetworkBase::write
static bool write(const Contact &contact, PortWriter &cmd, PortReader &reply, bool admin=false, bool quiet=false, double timeout=-1)
Send a single command to a port and await a single response.
Definition: Network.cpp:1229
yarp::serversql::impl::NameTripleState::remote
const yarp::os::Contact & remote
Definition: NameServiceOnTriples.h:35
yarp::serversql::impl::ParseName::getPortName
std::string getPortName()
Definition: ParseName.h:29
yarp::serversql::impl::ParseName::getNetworkChoice
std::string getNetworkChoice()
Definition: ParseName.h:39
yarp::serversql::impl::ParseName
Definition: ParseName.h:21
yarp::os::Bottle::fromString
void fromString(const std::string &text)
Initializes bottle from a string.
Definition: Bottle.cpp:207
yarp::serversql::impl::TripleSource
Abstract view of a database as a collection of triples.
Definition: TripleSource.h:44
yarp::serversql::impl::NameTripleState::nestedMode
bool nestedMode
Definition: NameServiceOnTriples.h:38
yarp::os::Bottle::find
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Bottle.cpp:290
yarp::os::SystemClock::nowSystem
static double nowSystem()
Definition: SystemClock.cpp:37
NestedContact.h
yarp::os::Bottle::check
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition: Bottle.cpp:280
LogComponent.h
yarp::serversql::impl::NameTripleState
State information for a single name server operation on a database.
Definition: NameServiceOnTriples.h:30
yarp::serversql::impl::TripleSource::query
virtual std::list< Triple > query(Triple &ti, TripleContext *context)=0
yarp::serversql::impl::NameTripleState::bottleMode
bool bottleMode
Definition: NameServiceOnTriples.h:37
yarp::os::Bottle::get
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
yarp::serversql::impl::TripleContext::setRid
void setRid(int rid)
Definition: TripleSource.h:33
yarp::os::Bottle::addList
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
Definition: Bottle.cpp:185
yarp::os::Contact::getPort
int getPort() const
Get the port number associated with this Contact for socket communication.
Definition: Contact.cpp:242
yarp::os::Contact::fromString
static Contact fromString(const std::string &txt)
Factory method.
Definition: Contact.cpp:142
yarp::os::Contact::getCarrier
std::string getCarrier() const
Get the carrier associated with this Contact for socket communication.
Definition: Contact.cpp:253
yarp::os::Value::asString
virtual std::string asString() const
Get string value.
Definition: Value.cpp:237
yarp::os::Bottle::addInt32
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
Definition: Bottle.cpp:143
yarp::os::Vocab::encode
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
Definition: Vocab.cpp:14
yarp::os::Bottle::addString
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Definition: Bottle.cpp:173
yarp::os::Bottle::addVocab
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
Definition: Bottle.cpp:167
yarp::os::Contact::setNestedContact
void setNestedContact(const yarp::os::NestedContact &nestedContact)
Sets the NestedContact containing extra information for this Contact.
Definition: Contact.cpp:269
yarp::os::Bottle::tail
Bottle tail() const
Get all but the first element of a bottle.
Definition: Bottle.cpp:391
yarp::os::Value::asInt32
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition: Value.cpp:207
NameServiceOnTriples.h
yCInfo
#define yCInfo(component,...)
Definition: LogComponent.h:135
yarp::os::NestedContact::fromString
bool fromString(const std::string &nFullName)
Definition: NestedContact.cpp:156
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
yarp::os::Contact::isValid
bool isValid() const
Checks if a Contact is tagged as valid.
Definition: Contact.cpp:301
yarp::serversql::impl::TripleSource::remove_query
virtual void remove_query(Triple &ti, TripleContext *context)=0
yarp::os::Value::fromString
void fromString(const char *str)
Set value to correspond to a textual representation.
Definition: Value.cpp:354
Vocab.h
yarp::serversql::impl::ParseName::apply
void apply(const std::string &str)
Definition: ParseName.cpp:17
yarp::os::Contact::getHost
std::string getHost() const
Get the host name associated with this Contact for socket communication.
Definition: Contact.cpp:231
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
yarp::serversql::impl::TripleSource::insert
virtual void insert(Triple &t, TripleContext *context)=0
Time.h
yarp::os::Bottle::add
void add(const Value &value)
Add a Value to the bottle, at the end of the list.
Definition: Bottle.cpp:339
yarp::os::Value::toString
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Value.cpp:359
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::serversql::impl
Definition: Allocator.h:18
yarp::serversql::impl::NameTripleState::cmd
yarp::os::Bottle & cmd
Definition: NameServiceOnTriples.h:32
yarp::serversql::impl::NameTripleState::reply
yarp::os::Bottle & reply
Definition: NameServiceOnTriples.h:33
yarp::serversql::impl::TripleSource::update
virtual void update(Triple &t, TripleContext *context)=0
yarp::serversql::impl::TripleSource::find
virtual int find(Triple &t, TripleContext *context)=0
yarp::serversql::impl::NameTripleState::event
yarp::os::Bottle & event
Definition: NameServiceOnTriples.h:34