YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
NameServiceOnTriples.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_SERVERSQL_IMPL_NAMESERVICEONTRIPLES_H
8#define YARP_SERVERSQL_IMPL_NAMESERVICEONTRIPLES_H
9
14#include <yarp/os/NameStore.h>
15#include <yarp/os/Semaphore.h>
16
17#include <mutex>
18
19namespace yarp::serversql::impl {
20
50
55{
56private:
57 TripleSource *db;
58 Allocator *alloc;
59 Subscriber *subscriber;
60 std::string lastRegister;
61 yarp::os::Contact serverContact;
62 std::mutex mutex;
64 bool gonePublic;
65 bool silent;
66 yarp::os::NameSpace *delegate;
67public:
69 db(nullptr),
70 alloc(nullptr),
71 subscriber(nullptr),
72 lastRegister(""),
73 mutex(),
74 access(1),
75 gonePublic(false),
76 silent(false),
77 delegate(nullptr)
78 {
79 }
80
82 Allocator *alloc,
83 const yarp::os::Contact& serverContact)
84 {
85 this->db = db;
86 this->alloc = alloc;
87 this->serverContact = serverContact;
88 }
89
90 void setSubscriber(Subscriber *subscriber)
91 {
92 this->subscriber = subscriber;
93 }
94
95 void setSilent(bool flag)
96 {
97 this->silent = flag;
98 }
99
100 yarp::os::Contact query(const std::string& portName,
101 NameTripleState& act,
102 const std::string& prefix,
103 bool nested = false);
104
105 bool announce(const std::string& name, int activity) override;
106
107 yarp::os::Contact query(const std::string& portName) override;
108
109 bool cmdQuery(NameTripleState& act, bool nested = false);
110
111 bool cmdRegister(NameTripleState& act);
112
114
115 bool cmdList(NameTripleState& act);
116
118
119 bool cmdSet(NameTripleState& act);
120
121 bool cmdGet(NameTripleState& act);
122
123 bool cmdCheck(NameTripleState& act);
124
125 bool cmdRoute(NameTripleState& act);
126
127 bool cmdGc(NameTripleState& act);
128
129 bool cmdHelp(NameTripleState& act);
130
131 bool apply(yarp::os::Bottle& cmd,
132 yarp::os::Bottle& reply,
133 yarp::os::Bottle& event,
134 const yarp::os::Contact& remote) override;
135
136 void goPublic() override
137 {
138 gonePublic = true;
139 }
140
141 void lock() override;
142
143 void unlock() override;
144
146 {
147 this->delegate = delegate;
148 }
149
151 {
152 return delegate;
153 }
154};
155
156} // namespace yarp::serversql::impl
157
158
159#endif // YARP_SERVERSQL_IMPL_NAMESERVICEONTRIPLES_H
Abstract interface for a name server operator.
Definition NameService.h:24
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
Represents how to reach a part of a YARP network.
Definition Contact.h:33
An abstract name space for ports.
Definition NameSpace.h:22
A class for thread synchronization and mutual exclusion.
Definition Semaphore.h:25
Abstract interface for allocating network resources.
Definition Allocator.h:37
An implementation of name service operators on a triple store.
bool cmdQuery(NameTripleState &act, bool nested=false)
void setDelegate(yarp::os::NameSpace *delegate)
void open(TripleSource *db, Allocator *alloc, const yarp::os::Contact &serverContact)
bool apply(yarp::os::Bottle &cmd, yarp::os::Bottle &reply, yarp::os::Bottle &event, const yarp::os::Contact &remote) override
bool announce(const std::string &name, int activity) override
yarp::os::Contact query(const std::string &portName, NameTripleState &act, const std::string &prefix, bool nested=false)
State information for a single name server operation on a database.
NameTripleState(yarp::os::Bottle &cmd, yarp::os::Bottle &reply, yarp::os::Bottle &event, const yarp::os::Contact &remote, TripleSource &mem)
Abstract interface for maintaining persistent connections.
Definition Subscriber.h:26
Abstract view of a database as a collection of triples.