nidas  v1.2-1520
Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
nidas::core::Sample Class Referenceabstract

Interface to a data sample. More...

#include <Sample.h>

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

Public Member Functions

 Sample (sampleType t=CHAR_ST)
 
virtual ~Sample ()
 
void setTimeTag (dsm_time_t val)
 
dsm_time_t getTimeTag () const
 Time-tag in non-leap microseconds since Jan 1, 1970 00:00 GMT. More...
 
void setId (dsm_sample_id_t val)
 Set the id portion of the sample header. More...
 
dsm_sample_id_t getId () const
 Get the id portion of the sample header. More...
 
void setRawId (dsm_sample_id_t val)
 Set the full, raw id portion of the sample header. More...
 
dsm_sample_id_t getRawId () const
 
void setSpSId (unsigned int val)
 Set the short id portion of the sample header, containing the sensor + sample ids. More...
 
unsigned int getSpSId () const
 Get the short id portion of the sample header. More...
 
void setDSMId (unsigned int val)
 Set the DSM (data system) id portion of the sample header. More...
 
unsigned int getDSMId () const
 Get the DSM (data system) id portion of the sample header. More...
 
unsigned int getDataByteLength () const
 Get the number of bytes in data portion of sample. More...
 
virtual void setDataLength (unsigned int val)=0
 Set the number of elements in data portion of sample. More...
 
virtual unsigned int getDataLength () const =0
 Get the number of elements in data portion of sample. More...
 
virtual sampleType getType () const =0
 Get the type of the sample. More...
 
unsigned int getHeaderLength () const
 Number of bytes in header. More...
 
const void * getHeaderPtr () const
 Get a pointer to the header portion of the sample. More...
 
virtual void * getVoidDataPtr ()=0
 Get a void* pointer to the data portion of the sample. More...
 
virtual const void * getConstVoidDataPtr () const =0
 Get a const void* pointer to the data portion of the sample. More...
 
virtual double getDataValue (unsigned int i) const =0
 Get the numeric value of data element i. More...
 
virtual void setDataValue (unsigned int i, double val)=0
 Set the value of data element i to a double. More...
 
virtual void setDataValue (unsigned int i, float val)=0
 Set the value of data element i to a float. More...
 
virtual unsigned int getAllocLength () const =0
 Get number of elements allocated in data portion of sample. More...
 
virtual unsigned int getAllocByteLength () const =0
 Get number of bytes allocated in data portion of sample. More...
 
virtual void allocateData (unsigned int val)=0
 Allocate a number of bytes of data. More...
 
virtual void reallocateData (unsigned int val)=0
 Re-allocate a number of bytes of data, saving old contents. More...
 
void holdReference () const
 Increment the reference count for this sample. More...
 
virtual void freeReference () const =0
 Decrement the reference count for this sample. More...
 

Protected Attributes

SampleHeader _header
 
int _refCount
 The reference count. More...
 
nidas::util::Mutex _refLock
 

Static Protected Attributes

static int _nsamps
 Global count of the number of samples in use by a process. More...
 

Detailed Description

Interface to a data sample.

A Sample contains a SampleHeader and some data.

Constructor & Destructor Documentation

nidas::core::Sample::Sample ( sampleType  t = CHAR_ST)
inline

References _nsamps.

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

References _nsamps.

Member Function Documentation

virtual void nidas::core::Sample::allocateData ( unsigned int  val)
pure virtual
virtual void nidas::core::Sample::freeReference ( ) const
pure virtual
virtual unsigned int nidas::core::Sample::getAllocByteLength ( ) const
pure virtual
virtual unsigned int nidas::core::Sample::getAllocLength ( ) const
pure virtual

Get number of elements allocated in data portion of sample.

Implemented in nidas::core::SampleT< DataT >, nidas::core::SampleT< double >, nidas::core::SampleT< float >, and nidas::core::SampleT< char >.

virtual const void* nidas::core::Sample::getConstVoidDataPtr ( ) const
pure virtual
unsigned int nidas::core::Sample::getDataByteLength ( ) const
inline
virtual unsigned int nidas::core::Sample::getDataLength ( ) const
pure virtual
virtual double nidas::core::Sample::getDataValue ( unsigned int  i) const
pure virtual
unsigned int nidas::core::Sample::getDSMId ( ) const
inline

Get the DSM (data system) id portion of the sample header.

References _header, and nidas::core::SampleHeader::getDSMId().

Referenced by NidsMerge::receiveAllowedDsm(), and NidsMerge::run().

unsigned int nidas::core::Sample::getHeaderLength ( ) const
inline
const void* nidas::core::Sample::getHeaderPtr ( ) const
inline

Get a pointer to the header portion of the sample.

References _header.

Referenced by nidas::core::operator<<().

dsm_sample_id_t nidas::core::Sample::getId ( ) const
inline
dsm_sample_id_t nidas::core::Sample::getRawId ( ) const
inline
unsigned int nidas::core::Sample::getSpSId ( ) const
inline

Get the short id portion of the sample header.

This is the portion of the id without the DSM id.

References _header, and nidas::core::SampleHeader::getSpSId().

Referenced by NidsMerge::run().

dsm_time_t nidas::core::Sample::getTimeTag ( ) const
inline

Time-tag in non-leap microseconds since Jan 1, 1970 00:00 GMT.

References _header, and nidas::core::SampleHeader::getTimeTag().

Referenced by SampleToDatabase::accumulate(), SampleCounter::accumulateData(), SampleCounter::accumulateSample(), nidas::dynld::BlockStats::addGoodSample(), nidas::core::SampleClock::addSampleDate(), nidas::core::CharacterSensor::adjustTimeTag(), nidas::core::DSMSensor::applyConversions(), nidas::dynld::raf::A2D_Serial::checkCkSum(), nidas::dynld::raf::SyncRecordSource::checkTime(), nidas::dynld::raf::SyncRecordSource::computeSlotIndex(), nidas::dynld::isff::NCAR_TRH::convertVariable(), nidas::dynld::BlockStats::endBadBlock(), nidas::dynld::raf::SyncServer::handleSample(), nidas::dynld::isff::NCAR_TRH::ifanFilter(), nidas::core::SampleMatcher::match(), nidas::dynld::raf::SyncServer::openStream(), nidas::core::SampleTimetagComparator::operator()(), nidas::core::SampleHeaderComparator::operator()(), nidas::core::FullSampleComparator::operator()(), nidas::dynld::raf::TwoD64_USB::process(), nidas::dynld::raf::SPP300_Serial::process(), nidas::dynld::raf::BCPD_Serial::process(), nidas::dynld::raf::CDP_Serial::process(), nidas::dynld::raf::SPP100_Serial::process(), nidas::dynld::raf::SPP200_Serial::process(), nidas::dynld::raf::Watlow::process(), nidas::dynld::isff::Licor7500::process(), nidas::dynld::raf::PIP_Serial::process(), nidas::dynld::raf::LamsNetSensor::process(), nidas::dynld::isff::ATIK_Sonic::process(), nidas::dynld::isff::CU_Coldwire::process(), nidas::dynld::TSI_CPC3772::process(), nidas::dynld::iss::WICORSensor::process(), nidas::dynld::IEEE_Float::process(), nidas::dynld::isff::CSI_IRGA_Sonic::process(), nidas::dynld::raf::UHSAS_Serial::process(), nidas::dynld::isff::Wind3D::process(), nidas::dynld::raf::CVI_LV_Input::process(), nidas::dynld::raf::VCSEL_Serial::process(), nidas::dynld::isff::CSAT3_Sonic::process(), nidas::dynld::isff::Wind2D::process(), nidas::dynld::raf::DSMAnalogSensor::process(), nidas::dynld::WxtSensor::process(), nidas::dynld::raf::SyncRecordReader::read(), nidas::dynld::isff::GOESOutput::receive(), nidas::core::NearestResampler::receive(), nidas::core::SampleAverager::receive(), nidas::dynld::raf::SyncRecordSource::receive(), MergeVerifier::reportBackward(), MergeVerifier::reportDuplicate(), MergeVerifier::reportMissing(), nidas::core::MessageStreamScanner::requestBiggerSample(), DataStats::restartStats(), MergeVerifier::run(), NidsMerge::run(), SensorExtract::run(), DmdA2dCk::run(), nidas::dynld::isff::GOESOutput::run(), nidas::core::SampleSorter::run(), nidas::dynld::raf::SyncRecordReader::scanHeader(), nidas::dynld::raf::SyncRecordSource::sendSyncHeader(), nidas::dynld::raf::SyncRecordSource::sendSyncRecord(), nidas::dynld::raf::Extract2D::setTimeStamp(), nidas::dynld::isff::WisardMote::unpack10thSec(), nidas::dynld::isff::WisardMote::unpackAccumSec(), and nidas::dynld::isff::WisardMote::unpackTsoil().

virtual sampleType nidas::core::Sample::getType ( ) const
pure virtual
virtual void* nidas::core::Sample::getVoidDataPtr ( )
pure virtual
void nidas::core::Sample::holdReference ( ) const
inline

Increment the reference count for this sample.

Sample supports a form of reference counting. See freeReference. We have to use a hack-like cast of the this pointer to a const so that holdReference can be used on a const Sample. The SamplePool class supports Sample reference counting.

References _refCount, _refLock, nidas::util::Mutex::lock(), and nidas::util::Mutex::unlock().

virtual void nidas::core::Sample::reallocateData ( unsigned int  val)
pure virtual

Re-allocate a number of bytes of data, saving old contents.

Implemented in nidas::core::SampleT< DataT >, nidas::core::SampleT< double >, nidas::core::SampleT< float >, and nidas::core::SampleT< char >.

virtual void nidas::core::Sample::setDataLength ( unsigned int  val)
pure virtual
virtual void nidas::core::Sample::setDataValue ( unsigned int  i,
double  val 
)
pure virtual

Set the value of data element i to a double.

No range checking of i is done.

Implemented in nidas::core::SampleT< DataT >, nidas::core::SampleT< double >, nidas::core::SampleT< float >, and nidas::core::SampleT< char >.

virtual void nidas::core::Sample::setDataValue ( unsigned int  i,
float  val 
)
pure virtual

Set the value of data element i to a float.

No range checking is of i done.

Implemented in nidas::core::SampleT< DataT >, nidas::core::SampleT< double >, nidas::core::SampleT< float >, and nidas::core::SampleT< char >.

void nidas::core::Sample::setDSMId ( unsigned int  val)
inline

Set the DSM (data system) id portion of the sample header.

References _header, and nidas::core::SampleHeader::setDSMId().

Referenced by ARLIngest::writeLine().

void nidas::core::Sample::setId ( dsm_sample_id_t  val)
inline

Set the id portion of the sample header.

The id typically identifies the data system and sensor of origin of the sample.

References _header, and nidas::core::SampleHeader::setId().

Referenced by nidas::dynld::StatisticsCruncher::computeStats(), nidas::dynld::isff::GOESOutput::connected(), nidas::dynld::ParoSci_202BG_P::createPressureSample(), nidas::dynld::raf::SidsNetSensor::createSamples(), nidas::dynld::raf::TwoD_USB::createSamples(), nidas::core::SampleAverager::flush(), nidas::core::NearestResampler::flush(), nidas::dynld::isff::NCAR_TRH::ifanFilter(), nidas::core::DriverSampleScanner::nextSample(), nidas::core::MessageStreamScanner::nextSampleByLength(), nidas::core::MessageStreamScanner::nextSampleSepBOM(), nidas::core::MessageStreamScanner::nextSampleSepEOM(), nidas::dynld::raf::SPP300_Serial::process(), nidas::dynld::raf::Watlow::process(), nidas::dynld::raf::BCPD_Serial::process(), nidas::dynld::raf::CDP_Serial::process(), nidas::dynld::raf::SPP100_Serial::process(), nidas::dynld::raf::SPP200_Serial::process(), nidas::dynld::iss::TiltSensor::process(), nidas::dynld::isff::Licor7500::process(), nidas::dynld::raf::PHIPS_UDP::process(), nidas::dynld::raf::PIP_Serial::process(), nidas::dynld::isff::ATIK_Sonic::process(), nidas::dynld::raf::LamsNetSensor::process(), nidas::dynld::isff::CU_Coldwire::process(), nidas::dynld::raf::TwoD_House::process(), nidas::dynld::GPS_Novatel_Serial::process(), nidas::dynld::ParoSci_202BG_T::process(), nidas::dynld::isff::MOSMote::process(), nidas::dynld::TSI_CPC3772::process(), nidas::dynld::GPS_NMEA_Serial::process(), nidas::dynld::isff::CSI_CRX_Binary::process(), nidas::dynld::raf::PSI9116_Sensor::process(), nidas::dynld::iss::WICORSensor::process(), nidas::dynld::IEEE_Float::process(), nidas::dynld::isff::CSI_IRGA_Sonic::process(), nidas::dynld::raf::UHSAS_Serial::process(), nidas::dynld::raf::CVI_LV_Input::process(), nidas::dynld::raf::LamsSensor::process(), nidas::dynld::raf::PPT_Serial::process(), nidas::dynld::IR104_Relays::process(), nidas::dynld::raf::A2DBoardTempSensor::process(), nidas::dynld::A2DSensor::process(), nidas::dynld::isff::CSAT3_Sonic::process(), nidas::dynld::DSC_PulseCounter::process(), nidas::dynld::DSC_Event::process(), nidas::dynld::isff::Wind2D::process(), nidas::dynld::raf::A2D_Serial::process(), nidas::dynld::DSC_FreqCounter::process(), nidas::dynld::raf::IRIGSensor::process(), nidas::dynld::raf::DSMAnalogSensor::process(), nidas::dynld::WxtSensor::process(), nidas::dynld::raf::DSMArincSensor::process(), nidas::dynld::isff::WisardMote::process(), nidas::dynld::raf::DSMArincSensor::processAlta(), nidas::dynld::raf::TwoD64_USB::processSOR(), nidas::dynld::raf::TwoD64_USB_v3::processSOR(), nidas::dynld::raf::DSMAnalogSensor::processTemperature(), nidas::dynld::isff::PacketInputStream::readSamples(), nidas::core::NearestResampler::receive(), nidas::core::SampleAverager::receive(), nidas::core::MessageStreamScanner::requestBiggerSample(), SensorExtract::run(), TestSource::run(), nidas::dynld::isff::GOESOutput::run(), nidas::dynld::SampleInputStream::sampleFromHeader(), nidas::core::CharacterSensor::searchSampleScanners(), and nidas::dynld::raf::SyncRecordSource::sendSyncHeader().

void nidas::core::Sample::setRawId ( dsm_sample_id_t  val)
inline

Set the full, raw id portion of the sample header.

This method is not typically used except when doing raw IO on a sample. The raw id contains an enumeration of the sample type, along with the fields returned by getId().

References _header, and nidas::core::SampleHeader::setRawId().

void nidas::core::Sample::setSpSId ( unsigned int  val)
inline

Set the short id portion of the sample header, containing the sensor + sample ids.

This is the portion of the id without the DSM id.

References _header, and nidas::core::SampleHeader::setSpSId().

Referenced by ARLIngest::writeLine().

void nidas::core::Sample::setTimeTag ( dsm_time_t  val)
inline

References _header, and nidas::core::SampleHeader::setTimeTag().

Referenced by nidas::core::SampleClock::addSampleDate(), nidas::core::CharacterSensor::adjustTimeTag(), nidas::dynld::raf::SyncRecordSource::allocateRecord(), nidas::dynld::StatisticsCruncher::computeStats(), nidas::dynld::isff::GOESOutput::connected(), nidas::dynld::ParoSci_202BG_P::createPressureSample(), nidas::dynld::raf::SidsNetSensor::createSamples(), nidas::dynld::raf::TwoD_USB::createSamples(), nidas::core::SampleAverager::flush(), nidas::core::NearestResampler::flush(), NidsMerge::flushSorter(), nidas::dynld::isff::NCAR_TRH::ifanFilter(), nidas::core::DriverSampleScanner::nextSample(), nidas::core::DatagramSampleScanner::nextSample(), nidas::core::MessageStreamScanner::nextSampleByLength(), nidas::core::MessageStreamScanner::nextSampleSepBOM(), nidas::core::MessageStreamScanner::nextSampleSepEOM(), nidas::dynld::raf::SPP300_Serial::process(), nidas::dynld::raf::Watlow::process(), nidas::dynld::raf::BCPD_Serial::process(), nidas::dynld::raf::CDP_Serial::process(), nidas::dynld::raf::SPP100_Serial::process(), nidas::dynld::raf::SPP200_Serial::process(), nidas::dynld::isff::Licor7500::process(), nidas::dynld::iss::TiltSensor::process(), nidas::dynld::raf::PHIPS_UDP::process(), nidas::dynld::raf::PIP_Serial::process(), nidas::dynld::raf::TwoD_House::process(), nidas::dynld::isff::ATIK_Sonic::process(), nidas::dynld::raf::LamsNetSensor::process(), nidas::dynld::isff::CU_Coldwire::process(), nidas::dynld::GPS_Novatel_Serial::process(), nidas::dynld::isff::MOSMote::process(), nidas::dynld::ParoSci_202BG_T::process(), nidas::dynld::TSI_CPC3772::process(), nidas::dynld::GPS_NMEA_Serial::process(), nidas::dynld::isff::CSI_CRX_Binary::process(), nidas::dynld::raf::PSI9116_Sensor::process(), nidas::dynld::iss::WICORSensor::process(), nidas::dynld::IEEE_Float::process(), nidas::dynld::isff::CSI_IRGA_Sonic::process(), nidas::dynld::raf::UHSAS_Serial::process(), nidas::dynld::raf::CVI_LV_Input::process(), nidas::dynld::raf::PPT_Serial::process(), nidas::dynld::raf::LamsSensor::process(), nidas::dynld::raf::VCSEL_Serial::process(), nidas::dynld::IR104_Relays::process(), nidas::dynld::raf::A2DBoardTempSensor::process(), nidas::dynld::A2DSensor::process(), nidas::dynld::isff::CSAT3_Sonic::process(), nidas::dynld::DSC_Event::process(), nidas::dynld::DSC_PulseCounter::process(), nidas::dynld::isff::Wind2D::process(), nidas::dynld::raf::A2D_Serial::process(), nidas::dynld::DSC_FreqCounter::process(), nidas::dynld::raf::IRIGSensor::process(), nidas::dynld::raf::DSMAnalogSensor::process(), nidas::dynld::WxtSensor::process(), nidas::dynld::raf::DSMArincSensor::process(), nidas::dynld::isff::WisardMote::process(), nidas::dynld::raf::DSMArincSensor::processAlta(), nidas::dynld::raf::TwoD64_USB::processSOR(), nidas::dynld::raf::TwoD64_USB_v3::processSOR(), nidas::dynld::raf::DSMAnalogSensor::processTemperature(), nidas::dynld::isff::PacketInputStream::readSamples(), nidas::core::NearestResampler::receive(), nidas::core::SampleAverager::receive(), nidas::core::MessageStreamScanner::requestBiggerSample(), MergeVerifier::run(), TestSource::run(), nidas::dynld::isff::GOESOutput::run(), nidas::core::SampleSorter::run(), nidas::dynld::SampleInputStream::sampleFromHeader(), nidas::core::CharacterSensor::searchSampleScanners(), nidas::dynld::raf::SyncRecordSource::sendSyncHeader(), and ARLIngest::writeLine().

Member Data Documentation

SampleHeader nidas::core::Sample::_header
protected
int Sample::_nsamps
staticprotected

Global count of the number of samples in use by a process.

Incremented in the constructor, decremented in the destructor. Useful for development debugging to track leaks.

Referenced by Sample(), and ~Sample().

int nidas::core::Sample::_refCount
mutableprotected

The reference count.

Referenced by holdReference().

nidas::util::Mutex nidas::core::Sample::_refLock
mutableprotected

Referenced by holdReference().


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