6 #ifndef DYNAMIC_GRAPH_SIGNAL_ARRAY_H 7 #define DYNAMIC_GRAPH_SIGNAL_ARRAY_H 8 #include <dynamic-graph/dynamic-graph-api.h> 9 #include <dynamic-graph/signal-base.h> 18 template <
class Time>
class SignalArray_const {
21 static const int DEFAULT_SIZE = 20;
24 std::vector<const SignalBase<Time> *> const_array;
25 unsigned int size, rank;
28 SignalArray_const<Time>(
const unsigned int &sizeARG = DEFAULT_SIZE)
29 : const_array(sizeARG), size(sizeARG), rank(0) {}
31 SignalArray_const<Time>(
const SignalBase<Time> &sig)
32 : const_array(DEFAULT_SIZE), size(DEFAULT_SIZE), rank(0) {
36 SignalArray_const<Time>(
const SignalArray<Time> &siga)
37 : const_array(siga.getSize()), size(siga.getSize()),
38 rank(siga.getSize()) {
39 for (
unsigned int i = 0; i < rank; ++i)
40 const_array[i] = &siga[i];
43 SignalArray_const<Time>(
const SignalArray_const<Time> &siga)
44 : const_array(siga.getSize()), size(siga.getSize()),
45 rank(siga.getSize()) {
46 for (
unsigned int i = 0; i < rank; ++i)
47 const_array[i] = &siga[i];
50 virtual ~SignalArray_const<Time>() {}
53 void addElmt(
const SignalBase<Time> *el) {
56 const_array.resize(size);
58 const_array[rank++] = el;
62 virtual SignalArray_const<Time> &operator<<(const SignalBase<Time> &sig) {
68 virtual const SignalBase<Time> &operator[](
const unsigned int &idx)
const {
69 return *const_array[idx];
71 virtual unsigned int getSize()
const {
return rank; }
75 SignalArray_const<Time> operator<<(const SignalBase<Time> &sig1,
76 const SignalBase<Time> &sig2) {
77 SignalArray_const<Time> res(sig1);
85 template <
class Time>
class SignalArray :
public SignalArray_const<Time> {
87 using SignalArray_const<Time>::DEFAULT_SIZE;
88 using SignalArray_const<Time>::size;
89 using SignalArray_const<Time>::rank;
92 mutable std::vector<SignalBase<Time> *> array;
95 SignalArray<Time>(
const unsigned int &sizeARG = DEFAULT_SIZE)
96 : SignalArray_const<Time>(0), array(sizeARG) {
100 SignalArray<Time>(SignalBase<Time> &sig)
101 : SignalArray_const<Time>(0), array(DEFAULT_SIZE) {
106 SignalArray<Time>(
const SignalArray<Time> &siga)
107 : SignalArray_const<Time>(siga.getSize()), array(siga.getSize()) {
108 rank = siga.getSize();
109 for (
unsigned int i = 0; i < rank; ++i)
113 virtual ~SignalArray<Time>() {}
116 void addElmt(SignalBase<Time> *el) {
118 size += DEFAULT_SIZE;
125 virtual SignalArray<Time> &operator<<(SignalBase<Time> &sig) {
130 virtual SignalArray_const<Time>
131 operator<<(const SignalBase<Time> &sig)
const {
132 SignalArray_const<Time> res(*
this);
137 virtual SignalBase<Time> &operator[](
const unsigned int &idx)
const {
142 template <
class Time>
143 SignalArray<Time> operator<<(SignalBase<Time> &sig1, SignalBase<Time> &sig2) {
144 SignalArray<Time> res(sig1);
149 DYNAMIC_GRAPH_DLLAPI
extern SignalArray<int> sotNOSIGNAL;