nidas v1.2.3
|
#include <Sample.h>
Public Member Functions | |
SampleChar (const char *buffer) | |
Construct a SampleT<char> initialized to the bytes in buffer. | |
void | setValues (std::initializer_list< char > values) |
sampleType | getType () const |
Get the type of the sample. | |
unsigned int | getDataLength () const |
Get number of elements of type DataT in data. | |
void | setDataLength (unsigned int val) |
Set the number of elements of type DataT in data. | |
void * | getVoidDataPtr () |
Get a void* pointer to the data portion of the sample. | |
const void * | getConstVoidDataPtr () const |
Get a const void* pointer to the data portion of the sample. | |
char * | getDataPtr () |
const char * | getConstDataPtr () const |
double | getDataValue (unsigned int i) const |
Implementation of virtual method. | |
void | setDataValue (unsigned int i, double val) |
Implementation of virtual method. | |
void | setDataValue (unsigned int i, float val) |
Implementation of virtual method. | |
unsigned int | getAllocLength () const |
Get number of elements allocated in data portion of sample. | |
unsigned int | getAllocByteLength () const |
Get number of bytes allocated in data portion of sample. | |
void | allocateData (unsigned int val) |
Allocate data. | |
void | reallocateData (unsigned int val) |
Re-allocate data, space, keeping contents. | |
void | freeReference () const |
Decrement the reference count for this 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. | |
unsigned int | getHeaderLength () const |
Number of bytes in header. | |
const void * | getHeaderPtr () const |
Get a pointer to the header portion of the sample. | |
void | holdReference () const |
Increment the reference count for this sample. | |
Static Public Member Functions | |
static unsigned int | getMaxDataLength () |
Maximum number of elements in data. | |
static int | sizeofDataType () |
Protected Attributes | |
char * | _data |
Pointer to the actual data. | |
unsigned int | _allocLen |
Number of bytes allocated in data. | |
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. | |
Construct a SampleT<char> initialized to the bytes in buffer.
The buffer must be null-terminated, and the null will be included in the Sample data.
buffer | null-terminated array of chars |
References nidas::core::SampleT< char >::allocateData(), buffer, nidas::core::SampleT< char >::getDataPtr(), nidas::core::getSample(), len, and nidas::core::SampleT< char >::setDataLength().
|
inlinevirtualinherited |
|
virtualinherited |
Decrement the reference count for this sample.
Free a reference to a sample.
If the reference count is zero, then put the Sample into the SamplePool. freeReference() can be performed on a const Sample. However if at any moment a user of a const Sample has called freeReference more times than they have called holdReference, then they have violated the contract of a const Sample. Once the sample goes back into the sample pool it may be altered.
Samples can be used like normal variables without reference counting: { SampleT< samp; // automatic variable samp.setTimeTag(99); ... } // automatic variable destroyed
Or the reference count capability can be used. Here one saves samples into a buffer, and then later pops them off.
void pushSample(const Sample* samp) { samp->holdReference(); buffer.push_back(samp); } const Sample* popSample() { const Sample* samp = buffer.back(); buffer.pop_back(); samp->freeReference(); return samp; }
// Get sample from SamplePool. // The reference count will be one after the sample // is fetched from the pool - holdReference is // called for you by SamplePool. Sample* samp = SamplePool::getInstance()->getSample(100); ... pushSample(samp); ... samp = popSample(); ... // When you're completely done with it, call freeReference(). samp->freeReference();
Return it to its pool if no-one is using it.
Implements nidas::core::Sample.
|
inlinevirtualinherited |
Get number of bytes allocated in data portion of sample.
Implements nidas::core::Sample.
|
inlinevirtualinherited |
Get number of elements allocated in data portion of sample.
Implements nidas::core::Sample.
|
inlineinherited |
|
inlinevirtualinherited |
Get a const void* pointer to the data portion of the sample.
Implements nidas::core::Sample.
Get the number of bytes in data portion of sample.
References nidas::core::Sample::_header, and nidas::core::SampleHeader::getDataByteLength().
Referenced by SampleCounter::accumulateSample(), nidas::dynld::SampleInputStream::checkUnexpectedEOF(), nidas::core::SampleT< DataT >::getDataLength(), nidas::dynld::SampleInputStream::nextSample(), nidas::core::DriverSampleScanner::nextSample(), nidas::dynld::AsciiOutput::receive(), nidas::core::SampleBuffer::run(), and nidas::core::SampleSorter::run().
|
inlinevirtualinherited |
Get number of elements of type DataT in data.
Implements nidas::core::Sample.
|
inlineinherited |
|
inlinevirtualinherited |
Implementation of virtual method.
Implements nidas::core::Sample.
Get the DSM (data system) id portion of the sample header.
References nidas::core::Sample::_header, and nidas::core::SampleHeader::getDSMId().
Referenced by nidas::core::NearestResamplerAtRate::connect().
Number of bytes in header.
References nidas::core::SampleHeader::getSizeOf().
Get a pointer to the header portion of the sample.
References nidas::core::Sample::_header.
Referenced by nidas::core::operator<<().
|
inlineinherited |
Get the id portion of the sample header.
References nidas::core::Sample::_header, and nidas::core::SampleHeader::getId().
Referenced by nidas::dynld::StatisticsCruncher::attach(), nidas::core::NearestResamplerAtRate::connect(), nidas::core::SampleAverager::connect(), nidas::core::NearestResampler::connect(), nidas::core::NearestResampler::ctorCommon(), nidas::core::Site::fromDOMElement(), nidas::core::NearestResamplerAtRate::NearestResamplerAtRate(), nidas::core::MessageStreamScanner::requestBiggerSample(), ExtractFast2D::run(), ExtractDMT::run(), SensorExtract::run(), and nidas::core::Site::validate().
|
inlinestaticinherited |
Maximum number of elements in data.
|
inlineinherited |
References nidas::core::Sample::_header, and nidas::core::SampleHeader::getRawId().
Get the short id portion of the sample header.
This is the portion of the id without the DSM id.
References nidas::core::Sample::_header, and nidas::core::SampleHeader::getSpSId().
|
inlineinherited |
Time-tag in non-leap microseconds since Jan 1, 1970 00:00 GMT.
References nidas::core::Sample::_header, and nidas::core::SampleHeader::getTimeTag().
Referenced by nidas::core::SampleSorter::flush(), nidas::dynld::SampleInputStream::nextSample(), nidas::dynld::raf::SyncServer::openStream(), nidas::dynld::isff::WisardMote::process(), nidas::dynld::raf::PSI9116_Sensor::process(), nidas::dynld::raf::SidsNetSensor::process(), nidas::core::MessageStreamScanner::requestBiggerSample(), DataStats::restartStats(), NidsMerge::run(), nidas::core::SampleSorter::run(), nidas::dynld::raf::SyncRecordSource::sendSyncRecord(), nidas::dynld::raf::Extract2D::setTimeStamp(), nidas::dynld::raf::Extract2D::setTimeStamp(), and nidas::dynld::isff::WisardMote::unpackTsoil().
|
inlinevirtualinherited |
Get the type of the sample.
Implements nidas::core::Sample.
|
inlinevirtualinherited |
Get a void* pointer to the data portion of the sample.
Implements nidas::core::Sample.
|
inlineinherited |
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 nidas::core::Sample::_refCount, nidas::core::Sample::_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().
|
inlinevirtualinherited |
Re-allocate data, space, keeping contents.
val | number of DataT's to allocated. |
Implements nidas::core::Sample.
|
inlinevirtualinherited |
Set the number of elements of type DataT in data.
val | number of elements. |
Implements nidas::core::Sample.
|
inlinevirtualinherited |
Implementation of virtual method.
Implements nidas::core::Sample.
|
inlinevirtualinherited |
Implementation of virtual method.
Implements nidas::core::Sample.
Set the DSM (data system) id portion of the sample header.
References nidas::core::Sample::_header, and nidas::core::SampleHeader::setDSMId().
|
inlineinherited |
Set the id portion of the sample header.
The id typically identifies the data system and sensor of origin of the sample.
References nidas::core::Sample::_header, and nidas::core::SampleHeader::setId().
Referenced by nidas::core::DriverSampleScanner::nextSample(), nidas::core::MessageStreamScanner::nextSampleByLength(), nidas::core::MessageStreamScanner::nextSampleSepBOM(), nidas::core::MessageStreamScanner::nextSampleSepEOM(), nidas::dynld::raf::DSMArincSensor::process(), and nidas::dynld::raf::DSMArincSensor::processAlta().
|
inlineinherited |
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 nidas::core::Sample::_header, and nidas::core::SampleHeader::setRawId().
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 nidas::core::Sample::_header, and nidas::core::SampleHeader::setSpSId().
|
inlineinherited |
References nidas::core::Sample::_header, and nidas::core::SampleHeader::setTimeTag().
Referenced by nidas::core::DriverSampleScanner::nextSample(), nidas::core::MessageStreamScanner::nextSampleByLength(), nidas::core::MessageStreamScanner::nextSampleSepBOM(), nidas::core::MessageStreamScanner::nextSampleSepEOM(), nidas::dynld::raf::CVI_LV_Input::process(), nidas::dynld::raf::UHSAS_Serial::process(), and nidas::core::SampleSorter::run().
|
inlineinherited |
|
inlinestaticinherited |
|
protectedinherited |
Number of bytes allocated in data.
|
protectedinherited |
Pointer to the actual data.
|
protectedinherited |
Referenced by nidas::core::Sample::getDataByteLength(), nidas::core::Sample::getDSMId(), nidas::core::Sample::getHeaderPtr(), nidas::core::Sample::getId(), nidas::core::Sample::getRawId(), nidas::core::Sample::getSpSId(), nidas::core::Sample::getTimeTag(), nidas::core::SampleT< DataT >::setDataLength(), nidas::core::Sample::setDSMId(), nidas::core::Sample::setId(), nidas::core::Sample::setRawId(), nidas::core::Sample::setSpSId(), and nidas::core::Sample::setTimeTag().
|
staticprotectedinherited |
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 nidas::core::Sample::Sample(), and nidas::core::Sample::~Sample().
|
mutableprotectedinherited |
The reference count.
Referenced by nidas::core::Sample::holdReference().
|
mutableprotectedinherited |
Referenced by nidas::core::Sample::holdReference().