DGtal  1.1.0
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 
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 
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
160  template <typename TValue>
161  class Signal
162  {
163 
164  public:
165  typedef TValue Value;
172  static Signal<TValue> G2();
173 
177  static Signal<TValue> H2();
178 
183 
188  static Signal<TValue> G2n( unsigned int n );
189 
193  static Signal<TValue> H2n( unsigned int n );
194 
198  static Signal<TValue> D2n( unsigned int n );
199 
200  // ----------------------- Standard services ----------------------------
201  public:
202 
207 
212 
213 
221  Signal( unsigned int size, int z, bool periodic,
222  const TValue & def = TValue( 0 ) );
223 
232  Signal( const TValue* t, unsigned int size, int z, bool periodic,
233  const TValue & def = TValue( 0 ) );
234 
239  Signal( const Signal<TValue> & other );
240 
247 
248 
257  void init( unsigned int s, int z = 0, bool p = false,
258  const TValue & def = TValue( 0 ) );
259 
269  void init( const TValue* t, unsigned int size, int z = 0, bool p = false,
270  const TValue & def = TValue( 0 ) );
271 
272 
276  unsigned int size() const;
277 
278  // ----------------------- Signal services ----------------------------
279  public:
280 
289  TValue & operator[]( int i );
290 
299  const TValue & operator[]( int i ) const;
300 
306  void setAll( const TValue & val = TValue( 0 ) );
307 
308 
315  void multiply( const TValue & val );
316 
327 
328  // ----------------------- Interface --------------------------------------
329  public:
330 
335  void selfDisplay ( std::ostream & out ) const;
336 
341  bool isValid() const;
342 
343 
344  // ------------------------- Datas --------------------------------------
345  private:
346 
351 
352  // ------------------------- Hidden services ----------------------------
353  protected:
354 
355 
356  }; // end of class Signal
357 
358 
365  template <typename TValue>
366  std::ostream&
367  operator<< ( std::ostream & out, const Signal<TValue> & object );
368 
369 } // namespace DGtal
370 
371 
373 // Includes inline functions.
374 #include "DGtal/math/Signal.ih"
375 
376 // //
378 
379 #endif // !defined Signal_h
380 
381 #undef Signal_RECURSES
382 #endif // else defined(Signal_RECURSES)
DGtal::SignalData::SignalData
SignalData(unsigned int s, int z=0, bool p=false, const Value &def=Value(0))
DGtal::Signal::operator[]
const TValue & operator[](int i) const
DGtal::Signal::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::Signal::~Signal
~Signal()
DGtal::SignalData::periodic
bool periodic
Definition: Signal.h:69
DGtal::SignalData
Definition: Signal.h:58
DGtal::SignalData::init
void init(unsigned int s, int z=0, bool p=false, const Value &def=Value(0))
DGtal::Signal::H2
static Signal< TValue > H2()
DGtal::Signal::size
unsigned int size() const
DGtal::SignalData::SignalData
SignalData(const SignalData &other)
DGtal::Signal::multiply
void multiply(const TValue &val)
DGtal::Signal::init
void init(const TValue *t, unsigned int size, int z=0, bool p=false, const TValue &def=TValue(0))
DGtal::Signal::operator*
Signal< TValue > operator*(const Signal< TValue > &G)
DGtal::Signal::H2n
static Signal< TValue > H2n(unsigned int n)
DGtal::Signal::Signal
Signal(unsigned int size, int z, bool periodic, const TValue &def=TValue(0))
DGtal::Signal::operator=
Signal< TValue > & operator=(const Signal< TValue > &other)
DGtal::SignalData::size
unsigned int size
the size of the array data.
Definition: Signal.h:64
DGtal::Signal::Signal
Signal(const TValue *t, unsigned int size, int z, bool periodic, const TValue &def=TValue(0))
DGtal::SignalData::zero
int zero
the true index of the zero abscissa.
Definition: Signal.h:66
DGtal::Signal::Signal
Signal()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::SignalData::data
Value * data
a dyn. array on Value s.
Definition: Signal.h:62
DGtal::SignalData::defaut
const Value & defaut() const
DGtal::SignalData::~SignalData
~SignalData()
DGtal::Signal
Aim: Represents a discrete signal, periodic or not. The signal can be passed by value since it is onl...
Definition: Signal.h:162
DGtal::SignalData::SignalData
SignalData(const Value *t, unsigned int size, int z=0, bool p=false, const Value &def=Value(0))
DGtal::Signal::m_data
CowPtr< SignalData< TValue > > m_data
Definition: Signal.h:350
DGtal::Signal::Value
TValue Value
Definition: Signal.h:165
DGtal::Signal::init
void init(unsigned int s, int z=0, bool p=false, const TValue &def=TValue(0))
DGtal::Signal::operator[]
TValue & operator[](int i)
DGtal::SignalData::Value
TValue Value
Definition: Signal.h:59
DGtal::SignalData::init
void init(const Value *t, unsigned int size, int z=0, bool p=false, const Value &def=Value(0))
DGtal::Signal::isValid
bool isValid() const
DGtal::Signal::D2n
static Signal< TValue > D2n(unsigned int n)
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::Signal::G2
static Signal< TValue > G2()
DGtal::SignalData::SignalData
SignalData()
DGtal::Signal::Signal
Signal(const Signal< TValue > &other)
DGtal::Signal::G2n
static Signal< TValue > G2n(unsigned int n)
DGtal::Signal::setAll
void setAll(const TValue &val=TValue(0))
DGtal::SignalData::operator=
SignalData & operator=(const SignalData &other)
DGtal::Signal::Delta
static Signal< TValue > Delta()
DGtal::CowPtr
Aim: Copy on write shared pointer.
Definition: CowPtr.h:68