nidas v1.2.3
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.
 
void setId (dsm_sample_id_t val)
 Set the id portion of the sample header.
 
dsm_sample_id_t getId () const
 Get the id portion of the sample header.
 
void setRawId (dsm_sample_id_t val)
 Set the full, raw id portion of the sample header.
 
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.
 
unsigned int getSpSId () const
 Get the short id portion of the sample header.
 
void setDSMId (unsigned int val)
 Set the DSM (data system) id portion of the sample header.
 
unsigned int getDSMId () const
 Get the DSM (data system) id portion of the sample header.
 
unsigned int getDataByteLength () const
 Get the number of bytes in data portion of sample.
 
virtual void setDataLength (unsigned int val)=0
 Set the number of elements in data portion of sample.
 
virtual unsigned int getDataLength () const =0
 Get the number of elements in data portion of sample.
 
virtual sampleType getType () const =0
 Get the type of the sample.
 
unsigned int getHeaderLength () const
 Number of bytes in header.
 
const voidgetHeaderPtr () const
 Get a pointer to the header portion of the sample.
 
virtual voidgetVoidDataPtr ()=0
 Get a void* pointer to the data portion of the sample.
 
virtual const voidgetConstVoidDataPtr () const =0
 Get a const void* pointer to the data portion of the sample.
 
virtual double getDataValue (unsigned int i) const =0
 Get the numeric value of data element i.
 
virtual void setDataValue (unsigned int i, double val)=0
 Set the value of data element i to a double.
 
virtual void setDataValue (unsigned int i, float val)=0
 Set the value of data element i to a float.
 
virtual unsigned int getAllocLength () const =0
 Get number of elements allocated in data portion of sample.
 
virtual unsigned int getAllocByteLength () const =0
 Get number of bytes allocated in data portion of sample.
 
virtual void allocateData (unsigned int val)=0
 Allocate a number of bytes of data.
 
virtual void reallocateData (unsigned int val)=0
 Re-allocate a number of bytes of data, saving old contents.
 
void holdReference () const
 Increment the reference count for this sample.
 
virtual void freeReference () const =0
 Decrement the reference count for this sample.
 

Protected Attributes

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

Static Protected Attributes

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

Detailed Description

Interface to a data sample.

A Sample contains a SampleHeader and some data.

Constructor & Destructor Documentation

◆ Sample()

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

References _nsamps.

◆ ~Sample()

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

References _nsamps.

Member Function Documentation

◆ allocateData()

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

◆ freeReference()

virtual void nidas::core::Sample::freeReference ( ) const
pure virtual

◆ getAllocByteLength()

virtual unsigned int nidas::core::Sample::getAllocByteLength ( ) const
pure virtual

◆ getAllocLength()

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< char >, nidas::core::SampleT< double >, and nidas::core::SampleT< float >.

◆ getConstVoidDataPtr()

virtual const void * nidas::core::Sample::getConstVoidDataPtr ( ) const
pure virtual

◆ getDataByteLength()

unsigned int nidas::core::Sample::getDataByteLength ( ) const
inline

◆ getDataLength()

virtual unsigned int nidas::core::Sample::getDataLength ( ) const
pure virtual

◆ getDataValue()

virtual double nidas::core::Sample::getDataValue ( unsigned int i) const
pure virtual

◆ getDSMId()

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 nidas::core::NearestResamplerAtRate::connect().

◆ getHeaderLength()

unsigned int nidas::core::Sample::getHeaderLength ( ) const
inline

Number of bytes in header.

References nidas::core::SampleHeader::getSizeOf().

◆ getHeaderPtr()

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<<().

◆ getId()

dsm_sample_id_t nidas::core::Sample::getId ( ) const
inline

◆ getRawId()

dsm_sample_id_t nidas::core::Sample::getRawId ( ) const
inline

◆ getSpSId()

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().

◆ getTimeTag()

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

◆ getType()

virtual sampleType nidas::core::Sample::getType ( ) const
pure virtual

◆ getVoidDataPtr()

virtual void * nidas::core::Sample::getVoidDataPtr ( )
pure virtual

◆ holdReference()

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::core::getSample(), nidas::util::Mutex::lock(), and nidas::util::Mutex::unlock().

Referenced by nidas::core::SamplePool< SampleType >::getSample(), and nidas::dynld::raf::LamsNetSensor::process().

◆ reallocateData()

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< char >, nidas::core::SampleT< double >, and nidas::core::SampleT< float >.

◆ setDataLength()

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

◆ setDataValue() [1/2]

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< char >, nidas::core::SampleT< double >, and nidas::core::SampleT< float >.

◆ setDataValue() [2/2]

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< char >, nidas::core::SampleT< double >, and nidas::core::SampleT< float >.

◆ setDSMId()

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().

◆ setId()

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

◆ setRawId()

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().

◆ setSpSId()

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().

◆ setTimeTag()

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

Member Data Documentation

◆ _header

SampleHeader nidas::core::Sample::_header
protected

◆ _nsamps

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().

◆ _refCount

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

The reference count.

Referenced by holdReference().

◆ _refLock

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

Referenced by holdReference().


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