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 --- */
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>
38  Object obj;
39  struct timeval timestamp;
40 };
41 
42 template <class Object>
43 class Mailbox : public dg::Entity {
44  public:
45  static const std::string CLASS_NAME;
46  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
47 
48  public:
50 
51  public:
52  Mailbox(const std::string &name);
53  ~Mailbox(void);
54 
55  void post(const Object &obj);
56  sotTimestampedObject &get(sotTimestampedObject &res, const int &dummy);
57 
58  Object &getObject(Object &res, const int &time);
59  struct timeval &getTimestamp(struct timeval &res, const int &time);
60 
61  bool hasBeenUpdated(void);
62 
63  protected:
64  boost::timed_mutex mainObjectMutex;
65  Object mainObject;
66  struct timeval mainTimeStamp;
67  bool update;
68 
69  public: /* --- SIGNALS --- */
73 };
74 
75 } /* namespace sot */
76 
77 template <class Object>
78 struct signal_io<sot::MailboxTimestampedObject<Object> >
79  : signal_io_unimplemented<sot::MailboxTimestampedObject<Object> > {};
80 
81 template <>
82 struct signal_io<timeval> : signal_io_unimplemented<timeval> {};
83 } /* namespace dynamicgraph */
84 
85 #endif // #ifndef __SOT_MAILBOX_HH
dynamicgraph::SignalTimeDependent< struct timeval, int > timeSOUT
Definition: mailbox.hh:72
virtual const std::string & getClassName(void) const
Definition: mailbox.hh:46
boost::timed_mutex mainObjectMutex
Definition: mailbox.hh:64
MailboxTimestampedObject< Object > sotTimestampedObject
Definition: mailbox.hh:49
dynamicgraph::SignalTimeDependent< Object, int > objSOUT
Definition: mailbox.hh:71
static const std::string CLASS_NAME
Definition: mailbox.hh:45
res
DummyClass dummy
Definition: test_signal.cpp:31
dynamicgraph::SignalTimeDependent< sotTimestampedObject, int > SOUT
Definition: mailbox.hh:70


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26