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
40 const int REPORT_TIME=5;
44 template <
class T>
class DataSource;
45 template <
class T>
class DataWriter;
46 template <
class T1,
class T2>
class DataSource2;
47 template <
class T1,
class T2>
class DataWriter2;
54 virtual ~DataSource() {}
55 virtual bool getDatum(T& datum) = 0;
65 IPreciselyTimed *pPrecTime;
78 IPreciselyTimed *pt=NULL) :
108 deltaT=
now-timePrevious;
122 if (
now-lastSpoke>REPORT_TIME)
124 yInfo(
"Read [%d] frames in %d[s], average period %.2lf[ms], min %.2lf[ms], max %.2lf[ms]\n",
127 (cumulativeT/counter)*1000,
128 minT*1000, maxT*1000);
137 T& datum = writer.
get();
139 dater.getDatum(datum);
143 stamp=pPrecTime->getLastInputStamp();
151 writer.
write(!canDrop);
157 template <
class T1,
class T2>
160 virtual ~DataSource2() {}
161 virtual bool getDatum(T1& datum1, T2& datum2) = 0;
165 template <
class T1,
class T2>
172 DataSource2<T1,T2>& dater;
179 DataSource2<T1,T2>& dater,
181 bool addStamp=
false) :
182 port1(port1), port2(port2), dater(dater), canDrop(canDrop),
189 void run()
override {
190 T1& datum1 = writer1.
get();
191 T2& datum2 = writer2.
get();
192 dater.getDatum(datum1,datum2);
198 writer1.
write(!canDrop);
199 writer2.
write(!canDrop);
Buffer outgoing data to a port.
void write(bool forceStrict=false)
Try to write the last buffer returned by PortWriterBuffer::get.
T & get()
A synonym of PortWriterBuffer::prepare.
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
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.