time-stamp.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_TIME_STAMP__HH
11 #define __SOT_TIME_STAMP__HH
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
18 #include <dynamic-graph/linear-algebra.h>
19 namespace dg = dynamicgraph;
20 
21 /* Classes standards. */
22 #ifndef WIN32
23 #include <sys/time.h>
24 #else /*WIN32*/
26 #endif /*WIN32*/
27 
28 /* SOT */
29 #include <dynamic-graph/all-signals.h>
30 #include <dynamic-graph/entity.h>
31 #include <sot/core/debug.hh>
32 
33 /* --------------------------------------------------------------------- */
34 /* --- API ------------------------------------------------------------- */
35 /* --------------------------------------------------------------------- */
36 
37 #if defined(WIN32)
38 #if defined(time_stamp_EXPORTS)
39 #define TimeStamp_EXPORT __declspec(dllexport)
40 #else
41 #define TimeStamp_EXPORT __declspec(dllimport)
42 #endif
43 #else
44 #define TimeStamp_EXPORT
45 #endif
46 
47 /* --------------------------------------------------------------------- */
48 /* --- CLASS ----------------------------------------------------------- */
49 /* --------------------------------------------------------------------- */
50 
51 namespace dynamicgraph {
52 namespace sot {
53 namespace dg = dynamicgraph;
54 
55 class TimeStamp_EXPORT TimeStamp : public dg::Entity {
56 public:
57  static const std::string CLASS_NAME;
58  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
59 
60 protected:
61  struct timeval val;
62  unsigned int offsetValue;
63  bool offsetSet;
64 
65 public:
66  /* --- CONSTRUCTION --- */
67  TimeStamp(const std::string &name);
68 
69 public: /* --- DISPLAY --- */
70  virtual void display(std::ostream &os) const;
71 
72 public: /* --- SIGNALS --- */
73  /* These signals can be called several time per period, given
74  * each time a different results. Useful for chronos. */
75  dg::Signal<dg::Vector, int> timeSOUT;
76  dg::Signal<double, int> timeDoubleSOUT;
77 
78  /* These signals can be called several time per period, but give
79  * always the same results different results. Useful for synchro. */
80  dg::SignalTimeDependent<dg::Vector, int> timeOnceSOUT;
81  dg::SignalTimeDependent<double, int> timeOnceDoubleSOUT;
82 
83 protected: /* --- SIGNAL FUNCTIONS --- */
84  dg::Vector &getTimeStamp(dg::Vector &res, const int &time);
85  double &getTimeStampDouble(const dg::Vector &vect, double &res);
86 };
87 
88 } /* namespace sot */
89 } /* namespace dynamicgraph */
90 
91 #endif /* #ifndef __SOT_SOT_HH */
utils-windows.hh
dynamicgraph::sot::TimeStamp::timeSOUT
dg::Signal< dg::Vector, int > timeSOUT
Definition: time-stamp.hh:75
TimeStamp_EXPORT
#define TimeStamp_EXPORT
Definition: time-stamp.hh:44
dynamicgraph::sot::TimeStamp::offsetSet
bool offsetSet
Definition: time-stamp.hh:63
dynamicgraph
Definition: abstract-sot-external-interface.hh:17
dynamicgraph::sot::TimeStamp::timeOnceSOUT
dg::SignalTimeDependent< dg::Vector, int > timeOnceSOUT
Definition: time-stamp.hh:80
debug.hh
dynamicgraph::sot::TimeStamp::offsetValue
unsigned int offsetValue
Definition: time-stamp.hh:62
dynamicgraph::sot::TimeStamp::timeDoubleSOUT
dg::Signal< double, int > timeDoubleSOUT
Definition: time-stamp.hh:76
dynamicgraph::sot::TimeStamp
Definition: time-stamp.hh:55
dynamicgraph::sot::TimeStamp::timeOnceDoubleSOUT
dg::SignalTimeDependent< double, int > timeOnceDoubleSOUT
Definition: time-stamp.hh:81
dynamicgraph::sot::TimeStamp::CLASS_NAME
static const std::string CLASS_NAME
Definition: time-stamp.hh:57
dynamicgraph::sot::TimeStamp::getClassName
virtual const std::string & getClassName(void) const
Definition: time-stamp.hh:58