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;
66public:
68 db(nullptr),
69 alloc(nullptr),
70 subscriber(nullptr),
71 lastRegister(""),
72 mutex(),
73 access(1),
74 gonePublic(false),
75 silent(false)
76 {
77 }
78
80 Allocator *alloc,
81 const yarp::os::Contact& serverContact)
82 {
83 this->db = db;
84 this->alloc = alloc;
85 this->serverContact = serverContact;
86 }
87
88 void setSubscriber(Subscriber *subscriber)
89 {
90 this->subscriber = subscriber;
91 }
92
93 void setSilent(bool flag)
94 {
95 this->silent = flag;
96 }
97
98 yarp::os::Contact query(const std::string& portName,
99 NameTripleState& act,
100 const std::string& prefix,
101 bool nested = false);
102
103 bool announce(const std::string& name, int activity) override;
104
105 yarp::os::Contact query(const std::string& portName) override;
106
107 bool cmdQuery(NameTripleState& act, bool nested = false);
108
109 bool cmdRegister(NameTripleState& act);
110
112
113 bool cmdList(NameTripleState& act);
114
116
117 bool cmdSet(NameTripleState& act);
118
119 bool cmdGet(NameTripleState& act);
120
121 bool cmdCheck(NameTripleState& act);
122
123 bool cmdRoute(NameTripleState& act);
124
125 bool cmdGc(NameTripleState& act);
126
127 bool cmdHelp(NameTripleState& act);
128
129 bool apply(yarp::os::Bottle& cmd,
130 yarp::os::Bottle& reply,
131 yarp::os::Bottle& event,
132 const yarp::os::Contact& remote) override;
133
134 void goPublic() override
135 {
136 gonePublic = true;
137 }
138
139 void lock() override;
140
141 void unlock() override;
142};
143
144} // namespace yarp::serversql::impl
145
146
147#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
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 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.