mailbox.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 #ifndef __SOT_MAILBOX_HH
11 #define __SOT_MAILBOX_HH
12 
13 /* --- SOT PLUGIN --- */
14 #include <dynamic-graph/all-signals.h>
15 #include <dynamic-graph/entity.h>
16 
17 /* --- BOOST --- */
18 #include <boost/thread/mutex.hpp>
19 #include <boost/thread/thread.hpp>
20 #include <boost/thread/xtime.hpp>
21 
22 /* --- STD --- */
23 #include <time.h>
24 #ifndef WIN32
25 #include <sys/time.h>
26 #else
28 #endif /*WIN32*/
29 #include <string>
30 
31 namespace dynamicgraph {
32 namespace sot {
33 
34 namespace dg = dynamicgraph;
35 
36 template <class Object> class Mailbox : public dg::Entity {
37 public:
38  static const std::string CLASS_NAME;
39  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
40 
41 public:
43  Object obj;
44  struct timeval timestamp;
45  };
46 
47 public:
48  Mailbox(const std::string &name);
49  ~Mailbox(void);
50 
51  void post(const Object &obj);
52  sotTimestampedObject &get(sotTimestampedObject &res, const int &dummy);
53 
54  Object &getObject(Object &res, const int &time);
55  struct timeval &getTimestamp(struct timeval &res, const int &time);
56 
57  bool hasBeenUpdated(void);
58 
59 protected:
60  boost::timed_mutex mainObjectMutex;
61  Object mainObject;
62  struct timeval mainTimeStamp;
63  bool update;
64 
65 public: /* --- SIGNALS --- */
66  dg::SignalTimeDependent<struct sotTimestampedObject, int> SOUT;
67  dg::SignalTimeDependent<Object, int> objSOUT;
68  dg::SignalTimeDependent<struct timeval, int> timeSOUT;
69 };
70 
71 } /* namespace sot */
72 } /* namespace dynamicgraph */
73 
74 #endif // #ifndef __SOT_MAILBOX_HH
utils-windows.hh
dynamicgraph::sot::Mailbox::mainObjectMutex
boost::timed_mutex mainObjectMutex
Definition: mailbox.hh:60
dynamicgraph::sot::Mailbox::getClassName
virtual const std::string & getClassName(void) const
Definition: mailbox.hh:39
dynamicgraph::sot::Mailbox::mainTimeStamp
struct timeval mainTimeStamp
Definition: mailbox.hh:62
dynamicgraph::sot::Mailbox::mainObject
Object mainObject
Definition: mailbox.hh:61
dynamicgraph
Definition: abstract-sot-external-interface.hh:17
dynamicgraph::sot::timestamp
Definition: trajectory.hh:83
dynamicgraph::sot::Mailbox::sotTimestampedObject::obj
Object obj
Definition: mailbox.hh:43
dynamicgraph::sot::Mailbox::CLASS_NAME
static const std::string CLASS_NAME
Definition: mailbox.hh:38
dynamicgraph::sot::Mailbox::getObject
Object & getObject(Object &res, const int &time)
Definition: mailbox.hxx:85
dynamicgraph::sot::Mailbox::get
sotTimestampedObject & get(sotTimestampedObject &res, const int &dummy)
Definition: mailbox.hxx:58
dynamicgraph::sot::Mailbox::objSOUT
dg::SignalTimeDependent< Object, int > objSOUT
Definition: mailbox.hh:67
dynamicgraph::sot::Mailbox
Definition: mailbox.hh:36
dynamicgraph::sot::Mailbox::update
bool update
Definition: mailbox.hh:63
dynamicgraph::sot::Mailbox::sotTimestampedObject
Definition: mailbox.hh:42
dynamicgraph::sot::Mailbox::timeSOUT
dg::SignalTimeDependent< struct timeval, int > timeSOUT
Definition: mailbox.hh:68
dynamicgraph::sot::Mailbox::getTimestamp
struct timeval & getTimestamp(struct timeval &res, const int &time)
Definition: mailbox.hxx:92
dynamicgraph::sot::Mailbox::post
void post(const Object &obj)
Definition: mailbox.hxx:74
dynamicgraph::sot::Mailbox::~Mailbox
~Mailbox(void)
Definition: mailbox.hxx:38
dynamicgraph::sot::Mailbox::Mailbox
Mailbox(const std::string &name)
Definition: mailbox.hxx:24
dynamicgraph::sot::Mailbox::SOUT
dg::SignalTimeDependent< struct sotTimestampedObject, int > SOUT
Definition: mailbox.hh:66
dynamicgraph::sot::Mailbox::hasBeenUpdated
bool hasBeenUpdated(void)
Definition: mailbox.hxx:45