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