nidas v1.2.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::core::NearestResampler Class Reference

A simple, nearest-point resampler, for generating merged samples from variables from one or more sample sources. More...

#include <NearestResampler.h>

Inheritance diagram for nidas::core::NearestResampler:
Inheritance graph
[legend]

Public Member Functions

 NearestResampler (const std::vector< const Variable * > &vars, bool nansVariable=true)
 Constructor.
 
 NearestResampler (const std::vector< Variable * > &vars, bool nansVariable=true)
 
 ~NearestResampler ()
 
SampleSourcegetRawSampleSource ()
 Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
 
SampleSourcegetProcessedSampleSource ()
 Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
 
std::list< const SampleTag * > getSampleTags () const
 Get the SampleTag of my merged output sample.
 
SampleTagIterator getSampleTagIterator () const
 Implementation of SampleSource::getSampleTagIterator().
 
void addSampleClient (SampleClient *client) throw ()
 Implementation of SampleSource::addSampleClient().
 
void removeSampleClient (SampleClient *client) throw ()
 Remove a SampleClient from this SampleSource.
 
void addSampleClientForTag (SampleClient *client, const SampleTag *) throw ()
 Add a Client for a given SampleTag.
 
void removeSampleClientForTag (SampleClient *client, const SampleTag *) throw ()
 Remove a SampleClient for a given SampleTag from this SampleSource.
 
int getClientCount () const throw ()
 How many SampleClients are currently in my list.
 
const SampleStatsgetSampleStats () const
 
void connect (SampleSource *src)
 Connect the resampler to a SampleSource.
 
void disconnect (SampleSource *src) throw ()
 
bool receive (const Sample *s) throw ()
 Implementation of SampleClient::receive().
 
void flush () throw ()
 Implementation of Resampler::flush().
 

Private Member Functions

void ctorCommon (const std::vector< const Variable * > &vars, bool nansVariable)
 Common tasks of constructors.
 
void addSampleTag (const SampleTag *tag) throw ()
 Add a SampleTag to this SampleSource.
 
void removeSampleTag (const SampleTag *tag) throw ()
 
NearestResampleroperator= (const NearestResampler &)
 No assignment.
 
 NearestResampler (const NearestResampler &x)
 No copy.
 

Private Attributes

SampleSourceSupport _source
 
SampleTag _outSample
 
std::vector< Variable * > _reqVars
 Requested variables.
 
std::map< Variable *, unsigned int_outVarIndices
 Index of each requested output variable in the output sample.
 
std::map< dsm_sample_id_t, std::vector< unsigned int > > _inmap
 For each input sample, first index of variable data values to be read.
 
std::map< dsm_sample_id_t, std::vector< unsigned int > > _lenmap
 For each input sample, length of variables to read.
 
std::map< dsm_sample_id_t, std::vector< unsigned int > > _outmap
 For each input sample, index into output sample of each variable.
 
unsigned int _ndataValues
 
unsigned int _outlen
 
unsigned int _master
 
int _nmaster
 
dsm_time_t_prevTT
 
dsm_time_t_nearTT
 
float_prevData
 
float_nearData
 
int_samplesSinceMaster
 
std::map< dsm_sample_id_t, unsigned int_ttOutOfOrder
 
bool _debug
 

Detailed Description

A simple, nearest-point resampler, for generating merged samples from variables from one or more sample sources.

The first variable added to NearestResample with the addVariable() method becomes the "master" variable. The time tags of the master variable become the output sample time tags, and values of other variables are merged into the output sample by associating those values with the nearest time tag to the master times.

The only requirement is that the samples which are fed to the receive() method should be sorted in time. It they aren't sorted some data will be lost. NearestResampler does not need to know sampling rates, and the sampling rates of the input variables, including the master variable, may vary.

Constructor & Destructor Documentation

◆ NearestResampler() [1/3]

NearestResampler::NearestResampler ( const std::vector< const Variable * > & vars,
bool nansVariable = true )

Constructor.

References ctorCommon().

◆ NearestResampler() [2/3]

NearestResampler::NearestResampler ( const std::vector< Variable * > & vars,
bool nansVariable = true )

◆ ~NearestResampler()

NearestResampler::~NearestResampler ( )

◆ NearestResampler() [3/3]

nidas::core::NearestResampler::NearestResampler ( const NearestResampler & x)
private

No copy.

Member Function Documentation

◆ addSampleClient()

void nidas::core::NearestResampler::addSampleClient ( SampleClient * client)
throw ( )
inlinevirtual

◆ addSampleClientForTag()

void nidas::core::NearestResampler::addSampleClientForTag ( SampleClient * client,
const SampleTag *  )
throw ( )
inlinevirtual

◆ addSampleTag()

void nidas::core::NearestResampler::addSampleTag ( const SampleTag * tag)
throw ( )
inlineprivatevirtual

◆ connect()

void NearestResampler::connect ( SampleSource * src)
virtual

◆ ctorCommon()

void NearestResampler::ctorCommon ( const std::vector< const Variable * > & vars,
bool nansVariable )
private

◆ disconnect()

void NearestResampler::disconnect ( SampleSource * src)
throw ( )
virtual

◆ flush()

void NearestResampler::flush ( )
throw ( )
virtual

◆ getClientCount()

int nidas::core::NearestResampler::getClientCount ( ) const
throw ( )
inlinevirtual

How many SampleClients are currently in my list.

Exceptions

)

Implements nidas::core::SampleSource.

References _source, and nidas::core::SampleSourceSupport::getClientCount().

◆ getProcessedSampleSource()

SampleSource * nidas::core::NearestResampler::getProcessedSampleSource ( )
inlinevirtual

Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.

SampleClients use this method to get a pointer to whatever sample source they are interested in. Derived classes can return NULL if they are not a SampleSource of processed samples.

Implements nidas::core::SampleSource.

References _source.

◆ getRawSampleSource()

SampleSource * nidas::core::NearestResampler::getRawSampleSource ( )
inlinevirtual

Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.

SampleClients use this method to get a pointer to whatever sample source they are interested in. Derived classes can return NULL if they are not a SampleSource of raw samples.

Implements nidas::core::SampleSource.

◆ getSampleStats()

const SampleStats & nidas::core::NearestResampler::getSampleStats ( ) const
inlinevirtual

◆ getSampleTagIterator()

SampleTagIterator nidas::core::NearestResampler::getSampleTagIterator ( ) const
inlinevirtual

◆ getSampleTags()

std::list< const SampleTag * > nidas::core::NearestResampler::getSampleTags ( ) const
inlinevirtual

Get the SampleTag of my merged output sample.

Implements nidas::core::SampleSource.

References _source, and nidas::core::SampleSourceSupport::getSampleTags().

◆ operator=()

NearestResampler & nidas::core::NearestResampler::operator= ( const NearestResampler & )
private

No assignment.

◆ receive()

bool NearestResampler::receive ( const Sample * s)
throw ( )
virtual

◆ removeSampleClient()

void nidas::core::NearestResampler::removeSampleClient ( SampleClient * c)
throw ( )
inlinevirtual

◆ removeSampleClientForTag()

void nidas::core::NearestResampler::removeSampleClientForTag ( SampleClient * c,
const SampleTag *  )
throw ( )
inlinevirtual

Remove a SampleClient for a given SampleTag from this SampleSource.

The pointer to the SampleClient must remain valid, until after it is removed.

Exceptions

)

Implements nidas::core::SampleSource.

References _source, and nidas::core::SampleSourceSupport::removeSampleClient().

◆ removeSampleTag()

void nidas::core::NearestResampler::removeSampleTag ( const SampleTag * )
throw ( )
inlineprivatevirtual

Member Data Documentation

◆ _debug

bool nidas::core::NearestResampler::_debug
private

Referenced by ctorCommon().

◆ _inmap

std::map<dsm_sample_id_t,std::vector<unsigned int> > nidas::core::NearestResampler::_inmap
private

For each input sample, first index of variable data values to be read.

Referenced by connect().

◆ _lenmap

std::map<dsm_sample_id_t,std::vector<unsigned int> > nidas::core::NearestResampler::_lenmap
private

For each input sample, length of variables to read.

Referenced by connect().

◆ _master

unsigned int nidas::core::NearestResampler::_master
private

Referenced by ctorCommon(), and flush().

◆ _ndataValues

unsigned int nidas::core::NearestResampler::_ndataValues
private

Referenced by ctorCommon(), and flush().

◆ _nearData

float* nidas::core::NearestResampler::_nearData
private

◆ _nearTT

dsm_time_t* nidas::core::NearestResampler::_nearTT
private

◆ _nmaster

int nidas::core::NearestResampler::_nmaster
private

Referenced by ctorCommon(), and flush().

◆ _outlen

unsigned int nidas::core::NearestResampler::_outlen
private

Referenced by ctorCommon(), and flush().

◆ _outmap

std::map<dsm_sample_id_t,std::vector<unsigned int> > nidas::core::NearestResampler::_outmap
private

For each input sample, index into output sample of each variable.

Referenced by connect().

◆ _outSample

SampleTag nidas::core::NearestResampler::_outSample
private

Referenced by ctorCommon(), and flush().

◆ _outVarIndices

std::map<Variable*,unsigned int> nidas::core::NearestResampler::_outVarIndices
private

Index of each requested output variable in the output sample.

Referenced by connect(), and ctorCommon().

◆ _prevData

float* nidas::core::NearestResampler::_prevData
private

◆ _prevTT

dsm_time_t* nidas::core::NearestResampler::_prevTT
private

◆ _reqVars

std::vector<Variable *> nidas::core::NearestResampler::_reqVars
private

Requested variables.

Referenced by connect(), ctorCommon(), and ~NearestResampler().

◆ _samplesSinceMaster

int* nidas::core::NearestResampler::_samplesSinceMaster
private

◆ _source

SampleSourceSupport nidas::core::NearestResampler::_source
private

◆ _ttOutOfOrder

std::map<dsm_sample_id_t,unsigned int> nidas::core::NearestResampler::_ttOutOfOrder
private

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