sot-core  4.10.1
Hierarchical task solver plug-in for dynamic-graph.
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 template <class Object> class Mailbox : public dynamicgraph::Entity {
35 public:
36  static const std::string CLASS_NAME;
37  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
38 
39 public:
41  Object obj;
42  struct timeval timestamp;
43  };
44 
45 public:
46  Mailbox(const std::string &name);
47  ~Mailbox(void);
48 
49  void post(const Object &obj);
50  sotTimestampedObject &get(sotTimestampedObject &res, const int &dummy);
51 
52  Object &getObject(Object &res, const int &time);
53  struct timeval &getTimestamp(struct timeval &res, const int &time);
54 
55  bool hasBeenUpdated(void);
56 
57 protected:
58  boost::timed_mutex mainObjectMutex;
59  Object mainObject;
60  struct timeval mainTimeStamp;
61  bool update;
62 
63 public: /* --- SIGNALS --- */
64  dynamicgraph::SignalTimeDependent<struct sotTimestampedObject, int> SOUT;
65  dynamicgraph::SignalTimeDependent<Object, int> objSOUT;
66  dynamicgraph::SignalTimeDependent<struct timeval, int> timeSOUT;
67 };
68 
69 } /* namespace sot */
70 } /* namespace dynamicgraph */
71 
72 #endif // #ifndef __SOT_MAILBOX_HH
Mailbox(const std::string &name)
Definition: mailbox.hxx:22
dynamicgraph::SignalTimeDependent< struct timeval, int > timeSOUT
Definition: mailbox.hh:66
virtual const std::string & getClassName(void) const
Definition: mailbox.hh:37
boost::timed_mutex mainObjectMutex
Definition: mailbox.hh:58
bool update
Definition: mailbox.hh:61
void post(const Object &obj)
Definition: mailbox.hxx:72
dynamicgraph::SignalTimeDependent< Object, int > objSOUT
Definition: mailbox.hh:65
~Mailbox(void)
Definition: mailbox.hxx:36
dynamicgraph::SignalTimeDependent< struct sotTimestampedObject, int > SOUT
Definition: mailbox.hh:64
static const std::string CLASS_NAME
Definition: mailbox.hh:36
Definition: mailbox.hh:34
struct timeval & getTimestamp(struct timeval &res, const int &time)
Definition: mailbox.hxx:90
Definition: trajectory.hh:80
bool hasBeenUpdated(void)
Definition: mailbox.hxx:43
struct timeval mainTimeStamp
Definition: mailbox.hh:60
Object mainObject
Definition: mailbox.hh:59
Definition: abstract-sot-external-interface.hh:17
Object & getObject(Object &res, const int &time)
Definition: mailbox.hxx:83