|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
10 #ifndef YARP_OS_BUFFEREDPORT_INL_H
11 #define YARP_OS_BUFFEREDPORT_INL_H
44 return port.open(name);
51 return port.open(contact, registerName);
57 return port.addOutput(name);
63 return port.addOutput(name, carrier);
69 return port.addOutput(contact);
98 return reader.getPendingReads();
101 template <
typename T>
107 template <
typename T>
110 return where().getName();
113 template <
typename T>
119 template <
typename T>
122 return writer.unprepare();
125 template <
typename T>
131 writer.write(forceStrict);
134 template <
typename T>
140 template <
typename T>
143 writer.waitForWrite();
146 template <
typename T>
150 reader.setStrict(strict);
153 template <
typename T>
156 if (!port.isOpen()) {
162 T* result = reader.read(shouldWait);
164 while (result ==
nullptr && shouldWait && !reader.isClosed() && !interrupted) {
165 result = reader.read(shouldWait);
170 template <
typename T>
173 return reader.lastRead();
176 template <
typename T>
179 return !port.isOpen();
182 template <
typename T>
186 this->reader.setReplier(reader);
189 template <
typename T>
196 template <
typename T>
200 port.setAdminReader(reader);
203 template <
typename T>
210 template <
typename T>
214 reader.useCallback(callback);
217 template <
typename T>
221 reader.useCallback(*
this);
224 template <
typename T>
228 reader.disableCallback();
231 template <
typename T>
234 return port.setEnvelope(envelope);
238 template <
typename T>
241 return reader.getEnvelope(envelope);
244 template <
typename T>
247 return port.getInputCount();
250 template <
typename T>
253 return port.getOutputCount();
256 template <
typename T>
259 return port.isWriting();
262 template <
typename T>
265 port.getReport(reporter);
268 template <
typename T>
271 port.setReporter(reporter);
274 template <
typename T>
277 port.resetReporter();
280 template <
typename T>
283 return reader.acquire();
286 template <
typename T>
289 reader.release(handle);
293 template <
typename T>
297 reader.setTargetPeriod(period);
300 template <
typename T>
303 return port.getType();
306 template <
typename T>
309 port.promiseType(typ);
312 template <
typename T>
315 port.setInputMode(expectInput);
318 template <
typename T>
321 port.setOutputMode(expectOutput);
324 template <
typename T>
327 port.setRpcMode(expectRpc);
330 template <
typename T>
333 return port.acquireProperties(readOnly);
336 template <
typename T>
339 port.releaseProperties(prop);
342 template <
typename T>
345 return port.includeNodeInName(flag);
348 #ifndef YARP_NO_DEPRECATED // Since YARP 3.3
351 template <
typename T>
354 return port.setCallbackLock(mutex);
359 template <
typename T>
362 return port.setCallbackLock(mutex);
365 template <
typename T>
368 return port.removeCallbackLock();
371 template <
typename T>
374 return port.lockCallback();
377 template <
typename T>
380 return port.tryLockCallback();
383 template <
typename T>
386 return port.unlockCallback();
389 template <
typename T>
399 template <
typename T>
402 bool ok = this->port.sharedOpen(port);
413 #endif // YARP_OS_BUFFEREDPORT_INL_H
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
void disableCallback() override
Remove a callback set up with useCallback()
bool addOutput(const std::string &name) override
Add an output connection to the specified port.
void waitForWrite()
Wait for any pending writes to complete.
bool lockCallback() override
Lock callbacks until unlockCallback() is called.
T * read(bool shouldWait=true) override
Read an available object from the port.
void release(void *handle) override
Return control to YARP of an object previously taken control of with the acquire() method.
void releaseProperties(Property *prop) override
End access unstructured port properties.
void setReplier(PortReader &reader) override
If a message is received that requires a reply, use this handler.
void getReport(PortReport &reporter) override
Get information on the state of the port - connections etc.
A callback for typed data from a port.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void unlockCallback() override
Unlock callbacks.
void setStrict(bool strict=true) override
Call this to strictly keep all messages, or allow old ones to be quietly dropped.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
virtual ~BufferedPort()
Destructor.
void promiseType(const Type &typ) override
Commit the port to a particular type of data.
A base class for objects that want information about port status changes.
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
bool isClosed() override
Returns whether the port associated with this reader has been closed.
void setOutputMode(bool expectOutput) override
Configure the port to allow or forbid outputs.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
A mini-server for network communication.
A mini-server for performing network communication in the background.
int getOutputCount() override
Determine how many output connections this port has.
void writeStrict()
Write the current object being returned by BufferedPort::prepare, waiting until any previous sends ar...
void * acquire() override
Take control of the last object read.
bool isWriting() override
Report whether the port is currently writing data.
void resetReporter() override
Remove the callback which is called upon any future connections and disconnections to/from the port.
int getPendingReads() override
Get the number of objects ready to be read.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
int getInputCount() override
Determine how many connections are arriving into this port.
Property * acquireProperties(bool readOnly) override
Access unstructured port properties.
Type getType() override
Get the type of data the port has committed to send/receive.
void setReader(PortReader &reader) override
Set an external reader for port data.
void enableBackgroundWrite(bool backgroundFlag)
control whether writing from this port is done in the background.
void useCallback()
Use own onRead() method as callback.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void setReporter(PortReport &reporter) override
Set a callback to be called upon any future connections and disconnections to/from the port.
std::string getName() const override
Get name of port.
void setAdminReader(PortReader &reader) override
Set an external reader for unrecognized administrative port messages.
void setInputMode(bool expectInput) override
Configure the port to allow or forbid inputs.
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
Contact where() const override
Returns information about how this port can be reached.
void includeNodeInName(bool flag) override
Choose whether to prepend a node name (if one is available) to the port's name.
void onRead(T &datum) override
Callback method.
bool setCallbackLock(yarp::os::Mutex *mutex) override
Add a lock to use when invoking callbacks.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
BufferedPort()
Constructor.
T * lastRead() override
Get the last data returned by read()
bool unprepare()
Give the last prepared object back to YARP without writing it.
void close() override
Stop port activity.
bool removeCallbackLock() override
Remove a lock on callbacks added with setCallbackLock()
bool getEnvelope(PortReader &envelope) override
Get the envelope information (e.g., a timestamp) from the last message received on the port.
Basic wrapper for mutual exclusion.
bool tryLockCallback() override
Try to lock callbacks until unlockCallback() is called.
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
void setTargetPeriod(double period) override
Try to provide data periodically.
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
void resume() override
Put the port back in an operative state after interrupt() has been called.
void promiseType(const Type &typ) override
Commit the port to a particular type of data.
A class for storing options and configuration information.
void setRpcMode(bool expectRpc) override
Configure the port to be RPC only.