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>
20 class SignalArray_const {
22 static const int DEFAULT_SIZE = 20;
25 std::vector<const SignalBase<Time> *> const_array;
26 unsigned int size, rank;
29 SignalArray_const<Time>(
const unsigned int &sizeARG = DEFAULT_SIZE)
30 : const_array(sizeARG), size(sizeARG), rank(0) {}
32 SignalArray_const<Time>(
const SignalBase<Time> &sig)
33 : const_array(DEFAULT_SIZE), size(DEFAULT_SIZE), rank(0) {
37 SignalArray_const<Time>(
const SignalArray<Time> &siga)
38 : const_array(siga.getSize()),
40 rank(siga.getSize()) {
41 for (
unsigned int i = 0; i < rank; ++i) const_array[i] = &siga[i];
44 SignalArray_const<Time>(
const SignalArray_const<Time> &siga)
45 : const_array(siga.getSize()),
47 rank(siga.getSize()) {
48 for (
unsigned int i = 0; i < rank; ++i) const_array[i] = &siga[i];
51 virtual ~SignalArray_const<Time>() {}
54 void addElmt(
const SignalBase<Time> *el) {
57 const_array.resize(size);
59 const_array[rank++] = el;
63 virtual SignalArray_const<Time> &operator<<(
const SignalBase<Time> &sig) {
69 virtual const SignalBase<Time> &operator[](
const unsigned int &idx)
const {
70 return *const_array[idx];
72 virtual unsigned int getSize()
const {
return rank; }
76 SignalArray_const<Time> operator<<(
const SignalBase<Time> &sig1,
77 const SignalBase<Time> &sig2) {
78 SignalArray_const<Time> res(sig1);
87 class SignalArray :
public SignalArray_const<Time> {
89 using SignalArray_const<Time>::DEFAULT_SIZE;
90 using SignalArray_const<Time>::size;
91 using SignalArray_const<Time>::rank;
94 mutable std::vector<SignalBase<Time> *> array;
97 SignalArray<Time>(
const unsigned int &sizeARG = DEFAULT_SIZE)
98 : SignalArray_const<Time>(0), array(sizeARG) {
102 SignalArray<Time>(SignalBase<Time> &sig)
103 : SignalArray_const<Time>(0), array(DEFAULT_SIZE) {
108 SignalArray<Time>(
const SignalArray<Time> &siga)
109 : SignalArray_const<Time>(siga.getSize()), array(siga.getSize()) {
110 rank = siga.getSize();
111 for (
unsigned int i = 0; i < rank; ++i) array[i] = &siga[i];
114 virtual ~SignalArray<Time>() {}
117 void addElmt(SignalBase<Time> *el) {
119 size += DEFAULT_SIZE;
126 virtual SignalArray<Time> &operator<<(SignalBase<Time> &sig) {
131 virtual SignalArray_const<Time> operator<<(
132 const SignalBase<Time> &sig)
const {
133 SignalArray_const<Time> res(*
this);
138 virtual SignalBase<Time> &operator[](
const unsigned int &idx)
const {
143 template <
class Time>
144 SignalArray<Time> operator<<(SignalBase<Time> &sig1, SignalBase<Time> &sig2) {
145 SignalArray<Time> res(sig1);
150 DYNAMIC_GRAPH_DLLAPI
extern SignalArray<int> sotNOSIGNAL;