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;
A mini-server for performing network communication in the background.
void setStrict(bool strict=true) override
Call this to strictly keep all messages, or allow old ones to be quietly dropped.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
A mini-server for network communication.
void setRpcMode(bool expectRpc) override
Configure the port to be RPC only.
void setInputMode(bool expectInput) override
Configure the port to allow or forbid inputs.
void includeNodeInName(bool flag) override
Choose whether to prepend a node name (if one is available) to the port's name.
void promiseType(const Type &typ) override
Commit the port to a particular type of data.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void setOutputMode(bool expectOutput) override
Configure the port to allow or forbid outputs.
A port specialized for reading data of a constant type published on a topic.
bool open(const Contact &contact, bool registerName=true) override
Start port operation with user-chosen network parameters.
void close() override
Stop port activity.
T * read(bool shouldWait=true)
Read a message from the port.
const Port & asPort() const override
Get the concrete Port being used for communication, const version.
virtual ~Subscriber()
Destructor.
void setStrict(bool strict=true)
bool topic(const std::string &name)
Set topic to subscribe to.
void onRead(T &datum) override
Callback method.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Subscriber(const std::string &name="")
Constructor.
void useCallback(TypedReaderCallback< T > &callback)
void setReader(PortReader &reader) override
Set an external reader for port data.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void resume() override
Put the port back in an operative state after interrupt() has been called.
Port & asPort() override
Get the concrete Port being used for communication.
A callback for typed data from a port.
The main, catch-all namespace for YARP.