|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
9 #ifndef YARP_OS_SUBSCRIBER_H
10 #define YARP_OS_SUBSCRIBER_H
37 buffered_port =
nullptr;
66 bool topic(
const std::string& name)
73 bool open(
const std::string& name)
override
76 return port.
open(name);
80 bool open(
const Contact& contact,
bool registerName =
true)
override
83 return port.
open(contact, registerName);
117 T*
read(
bool shouldWait =
true)
119 return buffer().read(shouldWait);
141 buffer().useCallback(callback);
146 buffer().useCallback(*
this);
151 buffer().disableCallback();
158 buffered_port->setStrict(strict);
169 return *buffered_port;
175 if (!buffered_port) {
176 buffered_port =
new BufferedPort<T>(port);
181 return *buffered_port;
188 delete buffered_port;
189 buffered_port =
nullptr;
196 #endif // YARP_OS_SUBSCRIBER_H
void resume() override
Put the port back in an operative state after interrupt() has been called.
void onRead(T &datum) override
Callback method.
void includeNodeInName(bool flag) override
Choose whether to prepend a node name (if one is available) to the port's name.
Subscriber(const std::string &name="")
Constructor.
Port & asPort() override
Get the concrete Port being used for communication.
T * read(bool shouldWait=true)
Read a message from the port.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void setStrict(bool strict=true)
A callback for typed data from a port.
void setStrict(bool strict=true) override
Call this to strictly keep all messages, or allow old ones to be quietly dropped.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
const Port & asPort() const override
Get the concrete Port being used for communication, const version.
void setReader(PortReader &reader) override
Set an external reader for port data.
A mini-server for network communication.
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
bool open(const Contact &contact, bool registerName=true) override
Start port operation with user-chosen network parameters.
void setRpcMode(bool expectRpc) override
Configure the port to be RPC only.
virtual ~Subscriber()
Destructor.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
The main, catch-all namespace for YARP.
A port specialized for reading data of a constant type published on a topic.
void setOutputMode(bool expectOutput) override
Configure the port to allow or forbid outputs.
void useCallback(TypedReaderCallback< T > &callback)
void setInputMode(bool expectInput) override
Configure the port to allow or forbid inputs.
bool topic(const std::string &name)
Set topic to subscribe to.
void promiseType(const Type &typ) override
Commit the port to a particular type of data.