YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Subscriber.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_SUBSCRIBER_H
8#define YARP_SERVERSQL_IMPL_SUBSCRIBER_H
9
12
13#include <string>
14#include <yarp/os/Vocab.h>
15#include <yarp/os/NameStore.h>
16#include <yarp/os/NameSpace.h>
17
18
19namespace yarp::serversql::impl {
20
26{
27public:
29 store(nullptr)
30 {
31 }
32
34 {
35 this->store = &store;
36 }
37
39 {
40 return store;
41 }
42
43 void clear()
44 {
45 manager.clear();
46 }
47
48 void connect(const std::string& src,
49 const std::string& dest)
50 {
51 manager.connect(src,dest);
52 }
53
54 void disconnect(const std::string& src,
55 const std::string& dest,
56 bool srcDrop)
57 {
58 manager.disconnect(src,dest,srcDrop);
59 }
60
61 virtual bool addSubscription(const std::string& src,
62 const std::string& dest,
63 const std::string& mode) = 0;
64
65 virtual bool removeSubscription(const std::string& src,
66 const std::string& dest) = 0;
67
68 virtual bool listSubscriptions(const std::string& src,
69 yarp::os::Bottle& reply) = 0;
70
71 virtual bool welcome(const std::string& port, int activity) = 0;
72
73 virtual bool setTopic(const std::string& port,
74 const std::string& structure, bool active) = 0;
75
76 virtual bool listTopics(yarp::os::Bottle& topics) = 0;
77
78 virtual bool setType(const std::string& family,
79 const std::string& structure,
80 const std::string& value) = 0;
81
82 virtual std::string getType(const std::string& family,
83 const std::string& structure) = 0;
84
85 bool apply(yarp::os::Bottle& cmd,
86 yarp::os::Bottle& reply,
87 yarp::os::Bottle& event,
88 const yarp::os::Contact& remote) override;
89
90 void onEvent(yarp::os::Bottle& event) override
91 {
92 }
93
94 int replyCode(bool flag)
95 {
96 return flag ? yarp::os::createVocab32('o', 'k')
97 : yarp::os::createVocab32('f', 'a', 'i', 'l');
98 }
99
100private:
101 yarp::os::NameStore *store;
102 ConnectManager manager;
103};
104
105} // namespace yarp::serversql::impl
106
107
108#endif // YARP_SERVERSQL_IMPL_SUBSCRIBER_H
FeatureMode mode
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
Abstract interface for a database of port names.
Definition NameStore.h:19
void connect(const std::string &src, const std::string &dest, bool positive=true)
void disconnect(const std::string &src, const std::string &dest, bool srcDrop)
Abstract interface for maintaining persistent connections.
Definition Subscriber.h:26
void disconnect(const std::string &src, const std::string &dest, bool srcDrop)
Definition Subscriber.h:54
void onEvent(yarp::os::Bottle &event) override
Definition Subscriber.h:90
void setStore(yarp::os::NameStore &store)
Definition Subscriber.h:33
virtual bool listTopics(yarp::os::Bottle &topics)=0
yarp::os::NameStore * getStore()
Definition Subscriber.h:38
bool apply(yarp::os::Bottle &cmd, yarp::os::Bottle &reply, yarp::os::Bottle &event, const yarp::os::Contact &remote) override
virtual bool listSubscriptions(const std::string &src, yarp::os::Bottle &reply)=0
virtual bool setTopic(const std::string &port, const std::string &structure, bool active)=0
virtual bool removeSubscription(const std::string &src, const std::string &dest)=0
virtual bool addSubscription(const std::string &src, const std::string &dest, const std::string &mode)=0
virtual std::string getType(const std::string &family, const std::string &structure)=0
virtual bool welcome(const std::string &port, int activity)=0
virtual bool setType(const std::string &family, const std::string &structure, const std::string &value)=0
void connect(const std::string &src, const std::string &dest)
Definition Subscriber.h:48
constexpr yarp::conf::vocab32_t createVocab32(char a, char b=0, char c=0, char d=0)
Create a vocab from chars.
Definition Vocab32.h:27