DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Signal.h
1 
17 #pragma once
18 
31 #if defined(Signal_RECURSES)
32 #error Recursive header files inclusion detected in Signal.h
33 #else // defined(Signal_RECURSES)
34 
35 #define Signal_RECURSES
36 
37 #if !defined Signal_h
38 
39 #define Signal_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/CowPtr.h"
47 
48 namespace DGtal
49 {
50 
57  template <typename TValue>
58  struct SignalData {
59  typedef TValue Value;
60 
64  unsigned int size;
66  int zero;
69  bool periodic;
70 
75  SignalData();
76 
85  void init( unsigned int s, int z = 0, bool p = false,
86  const Value & def = Value( 0 ) );
87 
97  void init( const Value* t, unsigned int size, int z = 0, bool p = false,
98  const Value & def = Value( 0 ) );
99 
108  SignalData( unsigned int s, int z = 0, bool p = false,
109  const Value & def = Value( 0 ) );
110 
119  SignalData( const Value* t, unsigned int size, int z = 0, bool p = false,
120  const Value & def = Value( 0 ) );
121 
125  ~SignalData();
126 
131  SignalData( const SignalData & other );
132 
138  SignalData& operator=( const SignalData & other );
139 
144  const Value& defaut() const;
145  };
146 
147 
149  // template class Signal
161  template <typename TValue>
162  class Signal
163  {
164 
165  public:
166  typedef TValue Value;
173  static Signal<TValue> G2();
174 
178  static Signal<TValue> H2();
179 
183  static Signal<TValue> Delta();
184 
189  static Signal<TValue> G2n( unsigned int n );
190 
194  static Signal<TValue> H2n( unsigned int n );
195 
199  static Signal<TValue> D2n( unsigned int n );
200 
201  // ----------------------- Standard services ----------------------------
202  public:
203 
207  ~Signal();
208 
212  Signal();
213 
214 
222  Signal( unsigned int size, int z, bool periodic,
223  const TValue & def = TValue( 0 ) );
224 
233  Signal( const TValue* t, unsigned int size, int z, bool periodic,
234  const TValue & def = TValue( 0 ) );
235 
240  Signal( const Signal<TValue> & other );
241 
247  Signal<TValue> & operator=( const Signal<TValue> & other );
248 
249 
258  void init( unsigned int s, int z = 0, bool p = false,
259  const TValue & def = TValue( 0 ) );
260 
270  void init( const TValue* t, unsigned int size, int z = 0, bool p = false,
271  const TValue & def = TValue( 0 ) );
272 
273 
277  unsigned int size() const;
278 
279  // ----------------------- Signal services ----------------------------
280  public:
281 
290  TValue & operator[]( int i );
291 
300  const TValue & operator[]( int i ) const;
301 
307  void setAll( const TValue & val = TValue( 0 ) );
308 
309 
317  void multiply( const TValue & val );
318 
329 
330  // ----------------------- Interface --------------------------------------
331  public:
332 
337  void selfDisplay ( std::ostream & out ) const;
338 
343  bool isValid() const;
344 
345 
346  // ------------------------- Datas --------------------------------------
347  private:
348 
353 
354  // ------------------------- Hidden services ----------------------------
355  protected:
356 
357 
358  }; // end of class Signal
359 
360 
367  template <typename TValue>
368  std::ostream&
369  operator<< ( std::ostream & out, const Signal<TValue> & object );
370 
371 } // namespace DGtal
372 
373 
375 // Includes inline functions.
376 #include "DGtal/math/Signal.ih"
377 
378 // //
380 
381 #endif // !defined Signal_h
382 
383 #undef Signal_RECURSES
384 #endif // else defined(Signal_RECURSES)