reader.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_TRACER_H__
11 #define __SOT_TRACER_H__
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
18 #include <dynamic-graph/linear-algebra.h>
19 namespace dg = dynamicgraph;
20 
21 /* STD */
22 #include <boost/function.hpp>
23 #include <fstream>
24 #include <list>
25 #include <string>
26 #include <vector>
27 
28 /* SOT & DG*/
29 #include <dynamic-graph/entity.h>
30 #include <dynamic-graph/exception-traces.h>
31 #include <dynamic-graph/signal-base.h>
32 #include <dynamic-graph/signal-ptr.h>
33 #include <dynamic-graph/signal-time-dependent.h>
34 #include <sot/core/flags.hh>
35 
36 /* --------------------------------------------------------------------- */
37 /* --- API ------------------------------------------------------------- */
38 /* --------------------------------------------------------------------- */
39 
40 #if defined(WIN32)
41 #if defined(reader_EXPORTS)
42 #define SOTREADER_EXPORT __declspec(dllexport)
43 #else
44 #define SOTREADER_EXPORT __declspec(dllimport)
45 #endif
46 #else
47 #define SOTREADER_EXPORT
48 #endif
49 
50 /* --------------------------------------------------------------------- */
51 /* --- TRACER ---------------------------------------------------------- */
52 /* --------------------------------------------------------------------- */
53 
54 using dynamicgraph::Entity;
55 using dynamicgraph::SignalPtr;
56 using dynamicgraph::SignalTimeDependent;
58 
59 class SOTREADER_EXPORT sotReader : public Entity {
60  DYNAMIC_GRAPH_ENTITY_DECL();
61 
62 public:
63  SignalPtr<Flags, int> selectionSIN;
64  SignalTimeDependent<dg::Vector, int> vectorSOUT;
65  SignalTimeDependent<dg::Matrix, int> matrixSOUT;
66 
67 public:
68  sotReader(const std::string n);
69  virtual ~sotReader(void) {}
70 
71  void load(const std::string &filename);
72  void clear(void);
73  void rewind(void);
74 
75 protected:
76  typedef std::list<std::vector<double> > DataType;
78  DataType::const_iterator currentData;
80 
81  int rows, cols;
82 
83  dg::Vector &getNextData(dg::Vector &res, const unsigned int time);
84  dg::Matrix &getNextMatrix(dg::Matrix &res, const unsigned int time);
85  void resize(const int &nbRow, const int &nbCol);
86 
87 public:
88  /* --- PARAMS --- */
89  void display(std::ostream &os) const;
90  virtual void initCommands();
91 };
92 
93 #endif /* #ifndef __SOT_TRACER_H__ */
sotReader::rows
int rows
Definition: reader.hh:81
dynamicgraph
Definition: abstract-sot-external-interface.hh:17
SOTREADER_EXPORT
#define SOTREADER_EXPORT
Definition: reader.hh:47
sotReader::selectionSIN
SignalPtr< Flags, int > selectionSIN
Definition: reader.hh:63
sotReader::~sotReader
virtual ~sotReader(void)
Definition: reader.hh:69
sotReader::iteratorSet
bool iteratorSet
Definition: reader.hh:79
sotReader::dataSet
DataType dataSet
Definition: reader.hh:77
sotReader::matrixSOUT
SignalTimeDependent< dg::Matrix, int > matrixSOUT
Definition: reader.hh:65
flags.hh
sotReader
Definition: reader.hh:59
sotReader::currentData
DataType::const_iterator currentData
Definition: reader.hh:78
dynamicgraph::sot::Flags
Definition: flags.hh:31
sotReader::DataType
std::list< std::vector< double > > DataType
Definition: reader.hh:76
sotReader::vectorSOUT
SignalTimeDependent< dg::Vector, int > vectorSOUT
Definition: reader.hh:64