INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

stickinbuffercallback.h

00001 #ifndef GBXSERIALDEVICEACFR_STICKINBUFFERCALLBACK_H
00002 #define GBXSERIALDEVICEACFR_STICKINBUFFERCALLBACK_H
00003 
00004 #include <gbxsickacfr/gbxserialdeviceacfr/serialdevicehandler.h>
00005 #include <gbxsickacfr/gbxiceutilacfr/buffer.h>
00006 
00007 namespace gbxserialdeviceacfr {
00008 
00010 class TimedRxMsg {
00011 public:
00012 
00013     // Require an empty constructor to put in a buffer
00014     TimedRxMsg() {}
00015     TimedRxMsg( int s, int us, const RxMsgPtr &r )
00016         : timeStampSec(s), timeStampUsec(us), msg(r) {}
00017 
00018     int timeStampSec;
00019     int timeStampUsec;
00020     RxMsgPtr msg;
00021 };
00022 
00023 //
00024 // @brief simply sticks new messages into a thread-safe buffer
00025 //
00026 // @author Alex Brooks
00027 //
00028 class StickInBufferCallback : public RxMsgCallback
00029 {
00030 public: 
00031 
00032     StickInBufferCallback() {}
00033 
00034     // from RxMsgCallback
00035     void msgReceived( const RxMsgPtr &msg,
00036                       int             timeStampSec,
00037                       int             timeStampUsec )
00038         { rxMsgBuffer_.push( TimedRxMsg( timeStampSec, timeStampUsec, msg ) ); }
00039 
00040     // Allow external non-const access direct to (thread-safe) rxMsgBuffer.
00041     gbxiceutilacfr::Buffer<TimedRxMsg> &rxMsgBuffer() { return rxMsgBuffer_; }
00042 
00043 private: 
00044 
00045     // Thread-safe store of rxMsgs from the device
00046     gbxiceutilacfr::Buffer<TimedRxMsg> rxMsgBuffer_;
00047 };
00048 
00049 }
00050 
00051 #endif
 

Generated for GearBox by  doxygen 1.4.5