YARP
Yet Another Robot Platform
TypedReader.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_OS_TYPEDREADER_H
8 #define YARP_OS_TYPEDREADER_H
9 
10 
12 
13 
14 namespace yarp {
15 namespace os {
16 
21 template <class T>
23 {
24 public:
33  virtual void setStrict(bool strict = true) = 0;
34 
47  virtual T* read(bool shouldWait = true) = 0;
48 
52  virtual void interrupt() = 0;
53 
59  virtual T* lastRead() = 0;
60 
66  virtual bool isClosed() = 0;
67 
73  virtual void useCallback(TypedReaderCallback<T>& callback) = 0;
74 
78  virtual void disableCallback() = 0;
79 
84  virtual int getPendingReads() = 0;
85 
89  virtual ~TypedReader() = default;
90 
95  virtual std::string getName() const = 0;
96 
97 
105  virtual void setReplier(PortReader& reader) = 0;
106 
107 
119  virtual void* acquire() = 0;
120 
121 
129  virtual void release(void* handle) = 0;
130 
131 
140  virtual void setTargetPeriod(double period) = 0;
141 };
142 
143 } // namespace os
144 } // namespace yarp
145 
146 #endif // YARP_OS_TYPEDREADER_H
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:25
A callback for typed data from a port.
A base class for sources of typed data.
Definition: TypedReader.h:23
virtual void setReplier(PortReader &reader)=0
If a message is received that requires a reply, use this handler.
virtual void setStrict(bool strict=true)=0
Call this to strictly keep all messages, or allow old ones to be quietly dropped.
virtual void disableCallback()=0
Remove a callback set up with useCallback()
virtual void interrupt()=0
Abort any read operation currently in progress.
virtual T * lastRead()=0
Get the last data returned by read()
virtual std::string getName() const =0
Get name of port being read from.
virtual void release(void *handle)=0
Return control to YARP of an object previously taken control of with the acquire() method.
virtual int getPendingReads()=0
Check how many messages are waiting to be read.
virtual bool isClosed()=0
Returns whether the port associated with this reader has been closed.
virtual void useCallback(TypedReaderCallback< T > &callback)=0
Set an object whose onRead method will be called when data is available.
virtual void * acquire()=0
Take control of the last object read.
virtual T * read(bool shouldWait=true)=0
Read an available object from the port.
virtual ~TypedReader()=default
Destructor.
virtual void setTargetPeriod(double period)=0
Try to provide data periodically.
The main, catch-all namespace for YARP.
Definition: dirs.h:16