nidas  v1.2-1520
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::core::SampleSourceSupport Class Reference

A source of samples. More...

#include <SampleSourceSupport.h>

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

Public Member Functions

 SampleSourceSupport (bool raw)
 
 SampleSourceSupport (const SampleSourceSupport &x)
 Copy OK. More...
 
virtual ~SampleSourceSupport ()
 
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...
 
void addSampleTag (const SampleTag *tag) throw ()
 Add a SampleTag to this SampleSource. More...
 
void removeSampleTag (const SampleTag *tag) throw ()
 
std::list< const SampleTag * > getSampleTags () const
 What SampleTags am I a SampleSource for? More...
 
SampleTagIterator getSampleTagIterator () const
 
void addSampleClient (SampleClient *c) throw ()
 Add a SampleClient to this SampleSource. More...
 
void removeSampleClient (SampleClient *c) throw ()
 Remove a SampleClient from this SampleSource This will also remove a SampleClient if it has been added with addSampleClientForTag(). More...
 
void addSampleClientForTag (SampleClient *c, const SampleTag *) throw ()
 Add a SampleClient to this SampleSource. More...
 
void removeSampleClientForTag (SampleClient *c, const SampleTag *) throw ()
 Add a SampleClient to this SampleSource. More...
 
int getClientCount () const throw ()
 How many SampleClients are currently in my list. More...
 
void removeAllSampleClients () throw ()
 Big cleanup. More...
 
void distribute (const Sample *s) throw ()
 Distribute a sample to my clients, calling the receive() method of each client, passing the const pointer to the Sample. More...
 
void distribute (const std::list< const Sample * > &samps) throw ()
 Distribute a list of samples to my clients. More...
 
void flush () throw ()
 This implementation of SampleSource::flush() does nothing. More...
 
const SampleStatsgetSampleStats () const
 
void setKeepStats (bool val)
 
bool getKeepStats () const
 

Private Member Functions

SampleSourceSupportoperator= (const SampleSourceSupport &x)
 No assignment. More...
 

Private Attributes

nidas::util::Mutex _tagsMutex
 
std::list< const SampleTag * > _sampleTags
 
SampleClientList _clients
 Current clients of all samples. More...
 
std::map< dsm_sample_id_t,
SampleClientList
_clientsBySampleId
 Current clients of specific samples. More...
 
std::set< SampleClient * > _clientSet
 
nidas::util::Mutex _clientMapLock
 
SampleStats _stats
 
bool _raw
 
bool _keepStats
 

Detailed Description

A source of samples.

A SampleSource maintains a list of SampleClients. When a SampleSource has a Sample ready, it will call the receive method of all its SampleClients. SampleClients register/unregister with a SampleSource via the addSampleClient/removeSampleClient methods.

Constructor & Destructor Documentation

SampleSourceSupport::SampleSourceSupport ( bool  raw)
SampleSourceSupport::SampleSourceSupport ( const SampleSourceSupport x)

Copy OK.

A shallow copy, the SampleTags are copied to the new instance, but the SampleClients are not.

virtual nidas::core::SampleSourceSupport::~SampleSourceSupport ( )
inlinevirtual

Member Function Documentation

void SampleSourceSupport::addSampleClient ( SampleClient c)
throw (
)
virtual
void SampleSourceSupport::addSampleClientForTag ( SampleClient c,
const SampleTag tag 
)
throw (
)
virtual
void SampleSourceSupport::addSampleTag ( const SampleTag )
throw (
)
virtual
void SampleSourceSupport::distribute ( const Sample s)
throw (
)

Distribute a sample to my clients, calling the receive() method of each client, passing the const pointer to the Sample.

Does a s->freeReference() on the sample when done, which means you should assume that the pointer to the Sample is invalid after the call to distribute(), unless the owner has done an additional holdReference(). If so, it is very bad form to make any changes to Sample after the distribute() - the clients may get a half-changed Sample.

References nidas::core::SampleClientList::begin(), and nidas::core::SampleClientList::end().

Referenced by nidas::dynld::StatisticsCruncher::computeStats(), nidas::dynld::SampleInputStream::distribute(), nidas::core::DSMSensor::distributeRaw(), nidas::core::SampleAverager::flush(), nidas::core::NearestResampler::flush(), nidas::dynld::SampleInputStream::flush(), nidas::dynld::isff::PacketInputStream::readSamples(), nidas::dynld::SampleInputStream::readSamples(), nidas::core::DSMSensor::readSamples(), nidas::core::SampleBuffer::run(), nidas::core::SampleSorter::run(), nidas::dynld::raf::SyncRecordSource::sendSyncHeader(), and nidas::dynld::raf::SyncRecordSource::sendSyncRecord().

void SampleSourceSupport::distribute ( const std::list< const Sample * > &  samps)
throw (
)

Distribute a list of samples to my clients.

Calls receive() method of each client, passing the pointer to the Sample. Does a s->freeReference() on each sample in the list.

void nidas::core::SampleSourceSupport::flush ( )
throw (
)
inlinevirtual

This implementation of SampleSource::flush() does nothing.

Implements nidas::core::SampleSource.

int SampleSourceSupport::getClientCount ( ) const
throw (
)
virtual
bool nidas::core::SampleSourceSupport::getKeepStats ( ) const
inline
SampleSource* nidas::core::SampleSourceSupport::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 _raw.

Referenced by nidas::core::SampleBuffer::getProcessedSampleSource(), nidas::core::SampleSorter::getProcessedSampleSource(), and nidas::dynld::SampleInputStream::getProcessedSampleSource().

SampleSource* nidas::core::SampleSourceSupport::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.

References _raw.

Referenced by nidas::core::SampleSorter::flush(), nidas::core::SampleBuffer::getRawSampleSource(), nidas::core::SampleSorter::getRawSampleSource(), nidas::dynld::SampleInputStream::getRawSampleSource(), nidas::core::SampleBuffer::run(), and nidas::core::SampleSorter::run().

const SampleStats& nidas::core::SampleSourceSupport::getSampleStats ( ) const
inlinevirtual
SampleTagIterator SampleSourceSupport::getSampleTagIterator ( ) const
virtual
list< const SampleTag * > SampleSourceSupport::getSampleTags ( ) const
virtual
SampleSourceSupport& nidas::core::SampleSourceSupport::operator= ( const SampleSourceSupport x)
private

No assignment.

void nidas::core::SampleSourceSupport::removeAllSampleClients ( )
throw (
)
inline
void SampleSourceSupport::removeSampleClient ( SampleClient c)
throw (
)
virtual
void SampleSourceSupport::removeSampleClientForTag ( SampleClient c,
const SampleTag tag 
)
throw (
)
virtual
void SampleSourceSupport::removeSampleTag ( const SampleTag tag)
throw (
)
virtual
void nidas::core::SampleSourceSupport::setKeepStats ( bool  val)
inline

Member Data Documentation

nidas::util::Mutex nidas::core::SampleSourceSupport::_clientMapLock
private

Referenced by removeAllSampleClients().

SampleClientList nidas::core::SampleSourceSupport::_clients
private

Current clients of all samples.

Referenced by removeAllSampleClients().

std::map<dsm_sample_id_t,SampleClientList> nidas::core::SampleSourceSupport::_clientsBySampleId
private

Current clients of specific samples.

std::set<SampleClient*> nidas::core::SampleSourceSupport::_clientSet
private
bool nidas::core::SampleSourceSupport::_keepStats
private

Referenced by getKeepStats(), and setKeepStats().

bool nidas::core::SampleSourceSupport::_raw
private
std::list<const SampleTag*> nidas::core::SampleSourceSupport::_sampleTags
private

Referenced by getSampleTags().

SampleStats nidas::core::SampleSourceSupport::_stats
private

Referenced by getSampleStats().

nidas::util::Mutex nidas::core::SampleSourceSupport::_tagsMutex
mutableprivate

Referenced by getSampleTags().


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