7#ifndef YARPDB_NAMESERVERCONNECTIONHANDLER_INC
8#define YARPDB_NAMESERVERCONNECTIONHANDLER_INC
26class NameServerConnectionHandler;
41 this->service = service;
46 return apply(reader,
nullptr);
56 bool ok = cmd.
read(reader);
65 service->
apply(cmd,reply,event,remote);
66 for (
size_t i=0; i<
event.size(); i++) {
75 if (writer ==
nullptr) {
78 if (writer !=
nullptr) {
82 for (
size_t i=1; i<reply.
size(); i++) {
87 std::string si = v.
asList()->toString();
88 si.erase(std::remove(si.begin(), si.end(),
'\"'), si.end());
104 reply.
write(*writer);
Manage a single connection to the name server.
bool read(yarp::os::ConnectionReader &reader) override
Read this object from a network connection.
NameServerConnectionHandler(NameService *service)
virtual bool apply(yarp::os::ConnectionReader &reader, yarp::os::ConnectionWriter *writer, bool lock=true)
Abstract interface for a name server operator.
virtual void onEvent(yarp::os::Bottle &event)
virtual bool apply(yarp::os::Bottle &cmd, yarp::os::Bottle &reply, yarp::os::Bottle &event, const yarp::os::Contact &remote)=0
A simple collection of objects that can be described and transmitted in a portable way.
void add(const Value &value)
Add a Value to the bottle, at the end of the list.
size_type size() const
Gets the number of elements in the bottle.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
virtual Contact getRemoteContact() const =0
Gets information about who is supplying the data being read, if that information is available.
An interface for writing to a network connection.
virtual void appendText(const std::string &str, const char terminate='\n')=0
Send a terminated string to the network connection.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
A single value (typically within a Bottle).
virtual bool isString() const
Checks if value is a string.
virtual bool isList() const
Checks if value is a list.
virtual Bottle * asList() const
Get list value.
std::string toString() const override
Return a standard text representation of the content of the object.
virtual std::string asString() const
Get string value.