7#ifndef YARP_DEV_DATASOURCE_H
8#define YARP_DEV_DATASOURCE_H
12#if !defined(YARP_INCLUDING_DEPRECATED_HEADER_YARP_DEV_DATASOURCE_H_ON_PURPOSE)
16#ifndef YARP_NO_DEPRECATED
28#define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
30#undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
38#ifndef DOXYGEN_SHOULD_SKIP_THIS
40const int REPORT_TIME=5;
47template <
class T1,
class T2>
49template <
class T1,
class T2>
56 virtual ~DataSource() {}
57 virtual bool getDatum(T& datum) = 0;
67 IPreciselyTimed *pPrecTime;
80 IPreciselyTimed *pt=NULL) :
110 deltaT=
now-timePrevious;
124 if (
now-lastSpoke>REPORT_TIME)
126 yInfo(
"Read [%d] frames in %d[s], average period %.2lf[ms], min %.2lf[ms], max %.2lf[ms]\n",
129 (cumulativeT/counter)*1000,
130 minT*1000, maxT*1000);
139 T& datum = writer.
get();
141 dater.getDatum(datum);
145 stamp=pPrecTime->getLastInputStamp();
153 writer.
write(!canDrop);
159template <
class T1,
class T2>
162 virtual ~DataSource2() {}
163 virtual bool getDatum(T1& datum1, T2& datum2) = 0;
167template <
class T1,
class T2>
174 DataSource2<T1,T2>& dater;
181 DataSource2<T1,T2>& dater,
183 bool addStamp=
false) :
184 port1(port1), port2(port2), dater(dater), canDrop(canDrop),
191 void run()
override {
192 T1& datum1 = writer1.
get();
193 T2& datum2 = writer2.
get();
194 dater.getDatum(datum1,datum2);
200 writer1.
write(!canDrop);
201 writer2.
write(!canDrop);
Buffer outgoing data to a port.
T & get()
A synonym of PortWriterBuffer::prepare.
void write(bool forceStrict=false)
Try to write the last buffer returned by PortWriterBuffer::get.
void attach(Port &port)
Set the Port to which objects will be written.
A mini-server for network communication.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
A class that can be managed by another thread.
An abstraction for a time stamp and/or sequence number.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
#define YARP_DEPRECATED
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
yarp::rosmsg::std_msgs::Time Time
For streams capable of holding different kinds of content, check what they actually have.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
The main, catch-all namespace for YARP.
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
#define YARP_COMPILER_WARNING(x)
Generate a warning at build time on supported compilers.
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.