DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Data Fields
DGtal::SignalData< TValue > Struct Template Reference

#include <Signal.h>

Public Types

typedef TValue Value

Public Member Functions

 SignalData ()
void init (unsigned int s, int z=0, bool p=false, const Value &def=Value(0))
void init (const Value *t, unsigned int size, int z=0, bool p=false, const Value &def=Value(0))
 SignalData (unsigned int s, int z=0, bool p=false, const Value &def=Value(0))
 SignalData (const Value *t, unsigned int size, int z=0, bool p=false, const Value &def=Value(0))
 ~SignalData ()
 SignalData (const SignalData &other)
SignalDataoperator= (const SignalData &other)
const Valuedefaut () const

Data Fields

Valuedata
unsigned int size
int zero
bool periodic

Detailed Description

template<typename TValue>
struct DGtal::SignalData< TValue >

Represents the signal data.

Template Parameters:
TValuethe type chosen for each sample (generally float or double).

Definition at line 58 of file Signal.h.


Member Typedef Documentation

template<typename TValue>
typedef TValue DGtal::SignalData< TValue >::Value

Definition at line 59 of file Signal.h.


Constructor & Destructor Documentation

template<typename TValue >
DGtal::SignalData< TValue >::SignalData ( )
inline

Constructor. The object is not valid.

See also:
init.

Constructor.

Definition at line 45 of file Signal.ih.

: data( 0 )
{}
template<typename TValue >
DGtal::SignalData< TValue >::SignalData ( unsigned int  s,
int  z = 0,
bool  p = false,
const Value def = Value( 0 ) 
)
inline

Constructor.

Parameters:
sthe number of data in the signal.
zthe index of the zero-th element.
p'true' if the signal is periodic.
defthe default value.

Definition at line 104 of file Signal.ih.

: size( s ), zero( z ), periodic( p )
{
data = new TValue[ size + 1 ];
data[ size ] = def;
}
template<typename TValue >
DGtal::SignalData< TValue >::SignalData ( const Value t,
unsigned int  s,
int  z = 0,
bool  p = false,
const Value def = Value( 0 ) 
)
inline

Constructor.

Parameters:
tthe array containing initial data.
sizethe size of the signal.
zthe index of the zero-th element.
p'true' if the signal is periodic.
defthe default value.

Constructor.

Parameters:
tthe array containing initial data.
sthe number of data in the signal.
zthe index of the zero-th element.
p'true' if the signal is periodic.
defthe default value.

Definition at line 123 of file Signal.ih.

: size( s ), zero( z ), periodic( p )
{
data = new TValue[ size + 1 ];
for ( unsigned int i = 0; i < size; ++i )
data[ i ] = *t++;
data[ size ] = def;
}
template<typename TValue >
DGtal::SignalData< TValue >::~SignalData ( )
inline

Destructor.

Definition at line 138 of file Signal.ih.

{
if ( data != 0 ) delete[] data;
}
template<typename TValue >
DGtal::SignalData< TValue >::SignalData ( const SignalData< TValue > &  other)
inline

Copy constructor.

Parameters:
otherthe data to clone.

Definition at line 150 of file Signal.ih.

References DGtal::SignalData< TValue >::data.

: size( other.size ), zero( other.zero ), periodic( other.periodic )
{
if ( other.data != 0 )
{
data = new TValue[ size + 1 ];
for ( unsigned int i = 0; i <= size; ++i )
data[ i ] = other.data[ i ];
}
else
data = 0;
}

Member Function Documentation

template<typename TValue >
const TValue & DGtal::SignalData< TValue >::defaut ( ) const
inline

Default value.

Returns:
the default value.

Definition at line 207 of file Signal.ih.

Referenced by DGtal::Signal< TValue >::operator*().

{
ASSERT( data != 0 );
return data[ size ];
}
template<typename TValue >
void DGtal::SignalData< TValue >::init ( unsigned int  s,
int  z = 0,
bool  p = false,
const Value def = Value( 0 ) 
)
inline

Initializer.

Parameters:
sthe number of data in the signal.
zthe index of the zero-th element.
p'true' if the signal is periodic.
defthe default value.

Constructor.

Parameters:
sthe number of data in the signal.
zthe index of the zero-th element.
p'true' if the signal is periodic.
defthe default value.

Definition at line 61 of file Signal.ih.

{
if ( data != 0 ) delete[] data;
size = s; zero = z; periodic = p;
data = new TValue[ size + 1 ];
data[ size ] = def;
}
template<typename TValue >
void DGtal::SignalData< TValue >::init ( const Value t,
unsigned int  s,
int  z = 0,
bool  p = false,
const Value def = Value( 0 ) 
)
inline

Initializer.

Parameters:
tthe array containing initial data.
sizethe size of the signal.
zthe index of the zero-th element.
p'true' if the signal is periodic.
defthe default value.

Constructor.

Parameters:
tthe array containing initial data.
sthe number of data in the signal.
zthe index of the zero-th element.
p'true' if the signal is periodic.
defthe default value.

Definition at line 82 of file Signal.ih.

{
if ( data != 0 ) delete[] data;
size = s; zero = z; periodic = p;
data = new TValue[ size + 1 ];
for ( unsigned int i = 0; i < size; ++i, ++t )
data[ i ] = *t;
data[ size ] = def;
}
template<typename TValue >
DGtal::SignalData< TValue > & DGtal::SignalData< TValue >::operator= ( const SignalData< TValue > &  other)
inline

Assignment.

Parameters:
otherthe data to clone.
Returns:
'this'.

Definition at line 172 of file Signal.ih.

References DGtal::SignalData< TValue >::data, DGtal::SignalData< TValue >::periodic, DGtal::SignalData< TValue >::size, and DGtal::SignalData< TValue >::zero.

{
if ( this != &other )
{
if ( other.data == 0 )
{
if ( data != 0 )
delete[] data;
data = 0;
}
else
{
if ( size < other.size )
{
delete[] data;
data = new TValue[ other.size + 1 ];
}
size = other.size;
zero = other.zero;
periodic = other.periodic;
for ( unsigned int i = 0; i <= size; ++i )
data[ i ] = other.data[ i ];
}
}
return *this;
}

Field Documentation

template<typename TValue>
Value* DGtal::SignalData< TValue >::data
template<typename TValue>
bool DGtal::SignalData< TValue >::periodic

when 'true', the signal is periodic, otherwise infinite (with default value outside).

Definition at line 69 of file Signal.h.

Referenced by DGtal::Signal< TValue >::operator*(), DGtal::SignalData< TValue >::operator=(), and DGtal::Signal< TValue >::operator[]().

template<typename TValue>
unsigned int DGtal::SignalData< TValue >::size
template<typename TValue>
int DGtal::SignalData< TValue >::zero

the true index of the zero abscissa.

Definition at line 66 of file Signal.h.

Referenced by DGtal::Signal< TValue >::operator*(), DGtal::SignalData< TValue >::operator=(), and DGtal::Signal< TValue >::operator[]().


The documentation for this struct was generated from the following files: