signal-array.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
3 // JRL, CNRS/AIST.
4 //
5 
6 #ifndef DYNAMIC_GRAPH_SIGNAL_ARRAY_H
7 #define DYNAMIC_GRAPH_SIGNAL_ARRAY_H
10 #include <stdio.h>
11 
12 #include <vector>
13 
14 namespace dynamicgraph {
15 
19 template <class Time>
20 class SignalArray_const {
21  public:
22  static const int DEFAULT_SIZE = 20;
23 
24  protected:
25  std::vector<const SignalBase<Time> *> const_array;
26  unsigned int size, rank;
27 
28  public:
29  SignalArray_const<Time>(const unsigned int &sizeARG = DEFAULT_SIZE)
30  : const_array(sizeARG), size(sizeARG), rank(0) {}
31 
34  addElmt(&sig);
35  }
36 
38  : const_array(siga.getSize()),
39  size(siga.getSize()),
40  rank(siga.getSize()) {
41  for (unsigned int i = 0; i < rank; ++i) const_array[i] = &siga[i];
42  }
43 
45  : const_array(siga.getSize()),
46  size(siga.getSize()),
47  rank(siga.getSize()) {
48  for (unsigned int i = 0; i < rank; ++i) const_array[i] = &siga[i];
49  }
50 
52 
53  protected:
54  void addElmt(const SignalBase<Time> *el) {
55  if (rank >= size) {
56  size += DEFAULT_SIZE;
57  const_array.resize(size);
58  }
59  const_array[rank++] = el;
60  }
61 
62  public:
64  addElmt(&sig);
65  return *this;
66  }
67 
68  public:
69  virtual const SignalBase<Time> &operator[](const unsigned int &idx) const {
70  return *const_array[idx];
71  }
72  virtual unsigned int getSize() const { return rank; }
73 };
74 
75 template <class Time>
77  const SignalBase<Time> &sig2) {
78  SignalArray_const<Time> res(sig1);
79  res << sig2;
80  return res;
81 }
82 
86 template <class Time>
87 class SignalArray : public SignalArray_const<Time> {
88  public:
92 
93  protected:
94  mutable std::vector<SignalBase<Time> *> array;
95 
96  public:
97  SignalArray<Time>(const unsigned int &sizeARG = DEFAULT_SIZE)
98  : SignalArray_const<Time>(0), array(sizeARG) {
99  size = sizeARG;
100  }
101 
103  : SignalArray_const<Time>(0), array(DEFAULT_SIZE) {
104  size = DEFAULT_SIZE;
105  addElmt(&sig);
106  }
107 
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];
112  }
113 
114  virtual ~SignalArray<Time>() {}
115 
116  protected:
118  if (rank >= size) {
119  size += DEFAULT_SIZE;
120  array.resize(size);
121  }
122  array[rank++] = el;
123  }
124 
125  public:
127  addElmt(&sig);
128  return *this;
129  }
130 
132  const SignalBase<Time> &sig) const {
133  SignalArray_const<Time> res(*this);
134  res << sig;
135  return res;
136  }
137 
138  virtual SignalBase<Time> &operator[](const unsigned int &idx) const {
139  return *array[idx];
140  }
141 };
142 
143 template <class Time>
145  SignalArray<Time> res(sig1);
146  res << sig2;
147  return res;
148 }
149 
150 DYNAMIC_GRAPH_DLLAPI extern SignalArray<sigtime_t> sotNOSIGNAL;
151 
152 } // end of namespace dynamicgraph.
153 
154 #endif
dynamicgraph::operator<<
DYNAMIC_GRAPH_DLLAPI std::ostream & operator<<(std::ostream &os, const dynamicgraph::Entity &ent)
Definition: src/dgraph/entity.cpp:174
dynamicgraph::SignalArray_const::operator<<
virtual SignalArray_const< Time > & operator<<(const SignalBase< Time > &sig)
Definition: signal-array.h:63
dynamicgraph::SignalArray_const::DEFAULT_SIZE
static const int DEFAULT_SIZE
Definition: signal-array.h:22
dynamic-graph-api.h
dynamicgraph::SignalArray_const::operator[]
virtual const SignalBase< Time > & operator[](const unsigned int &idx) const
Definition: signal-array.h:69
dynamicgraph::SignalArray::operator<<
virtual SignalArray< Time > & operator<<(SignalBase< Time > &sig)
Definition: signal-array.h:126
dynamicgraph
dynamicgraph::SignalArray_const::rank
unsigned int rank
Definition: signal-array.h:26
dynamicgraph::SignalArray_const::addElmt
void addElmt(const SignalBase< Time > *el)
Definition: signal-array.h:54
dynamicgraph::SignalArray_const
TODO.
Definition: fwd.hh:50
dynamicgraph::SignalArray_const::size
unsigned int size
Definition: signal-array.h:26
signal-base.h
dynamicgraph::SignalArray::addElmt
void addElmt(SignalBase< Time > *el)
Definition: signal-array.h:117
sig
dynamicgraph::SignalArray_const< double > sig
Definition: signal-all.cpp:25
dynamicgraph::SignalArray::array
std::vector< SignalBase< Time > * > array
Definition: signal-array.h:94
dynamicgraph::SignalArray_const::getSize
virtual unsigned int getSize() const
Definition: signal-array.h:72
dynamicgraph::SignalArray_const::const_array
std::vector< const SignalBase< Time > * > const_array
Definition: signal-array.h:25
dynamicgraph::SignalArray
TODO.
Definition: fwd.hh:47
dynamicgraph::SignalArray::operator[]
virtual SignalBase< Time > & operator[](const unsigned int &idx) const
Definition: signal-array.h:138
dynamicgraph::SignalBase
The base class for signals: not to be used as such.
Definition: fwd.hh:53
dynamicgraph::sotNOSIGNAL
DYNAMIC_GRAPH_DLLAPI SignalArray< sigtime_t > sotNOSIGNAL


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Fri Aug 2 2024 08:36:38