YARP
Yet Another Robot Platform
NameService.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 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 #ifndef YARPDB_NAMESERVICE_INC
11 #define YARPDB_NAMESERVICE_INC
12 
13 #include <yarp/name/api.h>
14 #include <yarp/os/Bottle.h>
15 #include <yarp/os/Contact.h>
16 #include <yarp/os/NameStore.h>
17 
18 namespace yarp {
29  namespace name {
30  class NameService;
31  }
32 }
33 
40 public:
41  virtual ~NameService() {}
42 
43  virtual bool apply(yarp::os::Bottle& cmd,
44  yarp::os::Bottle& reply,
45  yarp::os::Bottle& event,
46  const yarp::os::Contact& remote) = 0;
47 
48  virtual void onEvent(yarp::os::Bottle& event) {}
49 
50  virtual void lock() {}
51  virtual void unlock() {}
52 
53  virtual void goPublic() {}
54 
55  yarp::os::Contact query(const std::string& name) override {
56  return yarp::os::Contact();
57  }
58 
59  bool announce(const std::string& name, int activity) override {
60  return false;
61  }
62 
65  const yarp::os::Contact& remote) override;
66 };
67 
68 
69 #endif
Abstract interface for a name server operator.
Definition: NameService.h:39
bool announce(const std::string &name, int activity) override
Definition: NameService.h:59
virtual void onEvent(yarp::os::Bottle &event)
Definition: NameService.h:48
virtual void lock()
Definition: NameService.h:50
virtual void goPublic()
Definition: NameService.h:53
bool process(yarp::os::PortWriter &in, yarp::os::PortReader &out, const yarp::os::Contact &remote) override
Definition: NameService.cpp:16
virtual void unlock()
Definition: NameService.h:51
virtual bool apply(yarp::os::Bottle &cmd, yarp::os::Bottle &reply, yarp::os::Bottle &event, const yarp::os::Contact &remote)=0
yarp::os::Contact query(const std::string &name) override
Definition: NameService.h:55
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:76
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
Abstract interface for a database of port names.
Definition: NameStore.h:23
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:27
The main, catch-all namespace for YARP.
Definition: environment.h:25
#define YARP_name_API
Definition: api.h:18