nidas  v1.2-1520
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. More...
 
 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. More...
 
SampleSourcegetProcessedSampleSource ()
 Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples. More...
 
std::list< const SampleTag * > getSampleTags () const
 Get the SampleTag of my merged output sample. More...
 
SampleTagIterator getSampleTagIterator () const
 Implementation of SampleSource::getSampleTagIterator(). More...
 
void addSampleClient (SampleClient *client) throw ()
 Implementation of SampleSource::addSampleClient(). More...
 
void removeSampleClient (SampleClient *client) throw ()
 Remove a SampleClient from this SampleSource. More...
 
void addSampleClientForTag (SampleClient *client, const SampleTag *) throw ()
 Add a Client for a given SampleTag. More...
 
void removeSampleClientForTag (SampleClient *client, const SampleTag *) throw ()
 Remove a SampleClient for a given SampleTag from this SampleSource. More...
 
int getClientCount () const throw ()
 How many SampleClients are currently in my list. More...
 
const SampleStatsgetSampleStats () const
 
void connect (SampleSource *src) throw (nidas::util::InvalidParameterException)
 Connect the resampler to a SampleSource. More...
 
void disconnect (SampleSource *src) throw ()
 
bool receive (const Sample *s) throw ()
 Implementation of SampleClient::receive(). More...
 
void flush () throw ()
 Implementation of Resampler::flush(). More...
 

Private Member Functions

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

Private Attributes

SampleSourceSupport _source
 
SampleTag _outSample
 
std::vector< Variable * > _reqVars
 Requested variables. More...
 
std::map< Variable *, unsigned
int > 
_outVarIndices
 Index of each requested output variable in the output sample. More...
 
std::map< dsm_sample_id_t,
std::vector< unsigned int > > 
_inmap
 For each input sample, first index of variable data values to be read. More...
 
std::map< dsm_sample_id_t,
std::vector< unsigned int > > 
_lenmap
 For each input sample, length of variables to read. More...
 
std::map< dsm_sample_id_t,
std::vector< unsigned int > > 
_outmap
 For each input sample, index into output sample of each variable. More...
 
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::NearestResampler ( const std::vector< const Variable * > &  vars,
bool  nansVariable = true 
)

Constructor.

References ctorCommon().

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

References ctorCommon().

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

No copy.

Member Function Documentation

void nidas::core::NearestResampler::addSampleClient ( SampleClient client)
throw (
)
inlinevirtual
void nidas::core::NearestResampler::addSampleClientForTag ( SampleClient client,
const SampleTag  
)
throw (
)
inlinevirtual
void nidas::core::NearestResampler::addSampleTag ( const SampleTag tag)
throw (
)
inlineprivatevirtual
void NearestResampler::connect ( SampleSource src)
throw (nidas::util::InvalidParameterException
)
virtual
void NearestResampler::ctorCommon ( const std::vector< const Variable * > &  vars,
bool  nansVariable 
)
private
void NearestResampler::disconnect ( SampleSource src)
throw (
)
virtual
void NearestResampler::flush ( )
throw (
)
virtual
int nidas::core::NearestResampler::getClientCount ( ) const
throw (
)
inlinevirtual

How many SampleClients are currently in my list.

Implements nidas::core::SampleSource.

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

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.

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.

const SampleStats& nidas::core::NearestResampler::getSampleStats ( ) const
inlinevirtual
SampleTagIterator nidas::core::NearestResampler::getSampleTagIterator ( ) const
inlinevirtual
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().

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

No assignment.

bool NearestResampler::receive ( const Sample s)
throw (
)
virtual
void nidas::core::NearestResampler::removeSampleClient ( SampleClient c)
throw (
)
inlinevirtual
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.

Implements nidas::core::SampleSource.

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

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

Member Data Documentation

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

Referenced by ctorCommon().

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.

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

For each input sample, length of variables to read.

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

Referenced by ctorCommon(), and flush().

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

Referenced by ctorCommon(), and flush().

float* nidas::core::NearestResampler::_nearData
private
dsm_time_t* nidas::core::NearestResampler::_nearTT
private
int nidas::core::NearestResampler::_nmaster
private

Referenced by ctorCommon(), and flush().

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

Referenced by ctorCommon(), and flush().

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.

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

Referenced by ctorCommon(), and flush().

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

Index of each requested output variable in the output sample.

Referenced by ctorCommon().

float* nidas::core::NearestResampler::_prevData
private
dsm_time_t* nidas::core::NearestResampler::_prevTT
private
std::vector<Variable *> nidas::core::NearestResampler::_reqVars
private

Requested variables.

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

int* nidas::core::NearestResampler::_samplesSinceMaster
private
SampleSourceSupport nidas::core::NearestResampler::_source
private
std::map<dsm_sample_id_t,unsigned int> nidas::core::NearestResampler::_ttOutOfOrder
private

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