YARP
Yet Another Robot Platform
TypedReader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_TYPEDREADER_H
11 #define YARP_OS_TYPEDREADER_H
12 
13 
15 
16 
17 namespace yarp {
18 namespace os {
19 
24 template <class T>
26 {
27 public:
36  virtual void setStrict(bool strict = true) = 0;
37 
50  virtual T* read(bool shouldWait = true) = 0;
51 
55  virtual void interrupt() = 0;
56 
62  virtual T* lastRead() = 0;
63 
69  virtual bool isClosed() = 0;
70 
76  virtual void useCallback(TypedReaderCallback<T>& callback) = 0;
77 
81  virtual void disableCallback() = 0;
82 
87  virtual int getPendingReads() = 0;
88 
92  virtual ~TypedReader() = default;
93 
98  virtual std::string getName() const = 0;
99 
100 
108  virtual void setReplier(PortReader& reader) = 0;
109 
110 
122  virtual void* acquire() = 0;
123 
124 
132  virtual void release(void* handle) = 0;
133 
134 
143  virtual void setTargetPeriod(double period) = 0;
144 };
145 
146 } // namespace os
147 } // namespace yarp
148 
149 #endif // YARP_OS_TYPEDREADER_H
yarp::os::TypedReader::setReplier
virtual void setReplier(PortReader &reader)=0
If a message is received that requires a reply, use this handler.
yarp::os::TypedReader
A base class for sources of typed data.
Definition: TypedReader.h:26
yarp::os::TypedReader::release
virtual void release(void *handle)=0
Return control to YARP of an object previously taken control of with the acquire() method.
yarp::os::TypedReader::read
virtual T * read(bool shouldWait=true)=0
Read an available object from the port.
yarp::os::TypedReader::disableCallback
virtual void disableCallback()=0
Remove a callback set up with useCallback()
yarp::os::TypedReaderCallback
A callback for typed data from a port.
Definition: TypedReaderCallback.h:31
yarp::os::TypedReader::setTargetPeriod
virtual void setTargetPeriod(double period)=0
Try to provide data periodically.
yarp::os::TypedReader::getName
virtual std::string getName() const =0
Get name of port being read from.
yarp::os::PortReader
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
yarp::os::TypedReader::~TypedReader
virtual ~TypedReader()=default
Destructor.
TypedReaderCallback.h
yarp::os::TypedReader::acquire
virtual void * acquire()=0
Take control of the last object read.
yarp::os::TypedReader::lastRead
virtual T * lastRead()=0
Get the last data returned by read()
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::TypedReader::useCallback
virtual void useCallback(TypedReaderCallback< T > &callback)=0
Set an object whose onRead method will be called when data is available.
yarp::os::TypedReader::getPendingReads
virtual int getPendingReads()=0
Check how many messages are waiting to be read.
yarp::os::TypedReader::isClosed
virtual bool isClosed()=0
Returns whether the port associated with this reader has been closed.
yarp::os::TypedReader::interrupt
virtual void interrupt()=0
Abort any read operation currently in progress.
yarp::os::TypedReader::setStrict
virtual void setStrict(bool strict=true)=0
Call this to strictly keep all messages, or allow old ones to be quietly dropped.