1 |
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 |
|
|
* Copyright Projet JRL-Japan, 2007 |
3 |
|
|
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 |
|
|
* |
5 |
|
|
* File: Selector.h |
6 |
|
|
* Project: SOT |
7 |
|
|
* Author: Nicolas Mansard |
8 |
|
|
* |
9 |
|
|
* Version control |
10 |
|
|
* =============== |
11 |
|
|
* |
12 |
|
|
* $Id$ |
13 |
|
|
* |
14 |
|
|
* Description |
15 |
|
|
* ============ |
16 |
|
|
* |
17 |
|
|
* |
18 |
|
|
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
19 |
|
|
|
20 |
|
|
#ifndef __SOT_Selector_H__ |
21 |
|
|
#define __SOT_Selector_H__ |
22 |
|
|
|
23 |
|
|
/* --------------------------------------------------------------------- */ |
24 |
|
|
/* --- INCLUDE --------------------------------------------------------- */ |
25 |
|
|
/* --------------------------------------------------------------------- */ |
26 |
|
|
|
27 |
|
|
/* SOT */ |
28 |
|
|
#include <dynamic-graph/entity.h> |
29 |
|
|
#include <dynamic-graph/signal-ptr.h> |
30 |
|
|
#include <dynamic-graph/signal-time-dependent.h> |
31 |
|
|
|
32 |
|
|
#include <sot/core/matrix-geometry.hh> |
33 |
|
|
|
34 |
|
|
/* STD */ |
35 |
|
|
#include <string> |
36 |
|
|
|
37 |
|
|
/* --------------------------------------------------------------------- */ |
38 |
|
|
/* --- API ------------------------------------------------------------- */ |
39 |
|
|
/* --------------------------------------------------------------------- */ |
40 |
|
|
|
41 |
|
|
#if defined(WIN32) |
42 |
|
|
#if defined(selector_EXPORTS) |
43 |
|
|
#define Selector_EXPORT __declspec(dllexport) |
44 |
|
|
#else |
45 |
|
|
#define Selector_EXPORT __declspec(dllimport) |
46 |
|
|
#endif |
47 |
|
|
#else |
48 |
|
|
#define Selector_EXPORT |
49 |
|
|
#endif |
50 |
|
|
|
51 |
|
|
namespace dynamicgraph { |
52 |
|
|
namespace sot { |
53 |
|
|
|
54 |
|
|
/* --------------------------------------------------------------------- */ |
55 |
|
|
/* --- CLASS ----------------------------------------------------------- */ |
56 |
|
|
/* --------------------------------------------------------------------- */ |
57 |
|
|
|
58 |
|
|
class Selector_EXPORT Selector : public Entity { |
59 |
|
|
public: |
60 |
|
|
DYNAMIC_GRAPH_ENTITY_DECL(); |
61 |
|
|
|
62 |
|
|
protected: |
63 |
|
|
/** Number of signal type. For each signal type, you have |
64 |
|
|
* one output and <nbEntries> inputs. */ |
65 |
|
|
unsigned int nbSignals; |
66 |
|
|
/** Number of possible values for the selector. For each entry, |
67 |
|
|
* you have one signal of each type. */ |
68 |
|
|
unsigned int nbEntries; |
69 |
|
|
|
70 |
|
|
public: /* --- CONSTRUCTION --- */ |
71 |
|
|
Selector(const std::string &name); |
72 |
|
|
virtual ~Selector(void); |
73 |
|
|
|
74 |
|
|
public: /* --- SIGNAL --- */ |
75 |
|
|
SignalPtr<unsigned int, int> selectorSIN; |
76 |
|
|
|
77 |
|
|
std::vector<std::vector<SignalBase<int> *> > inputsSIN; |
78 |
|
|
std::vector<SignalBase<int> *> outputsSOUT; |
79 |
|
|
|
80 |
|
|
public: /* --- FUNCTIONS --- */ |
81 |
|
|
template <class T> |
82 |
|
|
static T &computeSelection(const unsigned int &sigNum, |
83 |
|
|
std::vector<SignalBase<int> *> &entriesSIN, T &res, |
84 |
|
|
const int &time); |
85 |
|
|
|
86 |
|
|
template <class T> |
87 |
|
|
unsigned int createSignal(const std::string &shortname, |
88 |
|
|
const int &sigId = -1); |
89 |
|
|
|
90 |
|
|
void resetSignals(const unsigned int &nbEntries, |
91 |
|
|
const unsigned int &nbSignals); |
92 |
|
|
|
93 |
|
|
public: /* --- PARAMS --- */ |
94 |
|
|
void initCommands(void); |
95 |
|
|
virtual void commandLine(const std::string &cmdLine, |
96 |
|
|
std::istringstream &cmdArgs, std::ostream &os); |
97 |
|
|
|
98 |
|
|
void create(const std::string &name, const std::string &type, |
99 |
|
|
const int &sigId); |
100 |
|
|
std::string getTypeList(void); |
101 |
|
|
void getTypeList(std::ostream &os); |
102 |
|
|
}; |
103 |
|
|
|
104 |
|
|
} // namespace sot |
105 |
|
|
} // namespace dynamicgraph |
106 |
|
|
|
107 |
|
|
#endif // #ifndef __SOT_Selector_H__ |