nds2-client - ClientUser  0.16.8
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | List of all members
NDS::abi_0::buffer Class Reference

A buffer holds the data contents of a channel. More...

#include <nds.hh>

Inheritance diagram for NDS::abi_0::buffer:
Inheritance graph
[legend]
Collaboration diagram for NDS::abi_0::buffer:
Collaboration graph
[legend]

Public Types

typedef long gps_second_type
 Type second portion of a gps time.
 
typedef long gps_nanosecond_type
 Type nano second portion of a gps time.
 
typedef size_t size_type
 Type appropriate for length.
 
typedef std::vector< unsigned
char > 
data_type
 Storage type for the data.
 
- Public Types inherited from NDS::abi_0::channel
enum  channel_type {
  CHANNEL_TYPE_UNKNOWN = 0, CHANNEL_TYPE_ONLINE = ( 1 << 0 ), CHANNEL_TYPE_RAW = ( 1 << 1 ), CHANNEL_TYPE_RDS = ( 1 << 2 ),
  CHANNEL_TYPE_STREND = ( 1 << 3 ), CHANNEL_TYPE_MTREND = ( 1 << 4 ), CHANNEL_TYPE_TEST_POINT = ( 1 << 5 ), CHANNEL_TYPE_STATIC = ( 1 << 6 )
}
 
enum  data_type {
  DATA_TYPE_UNKNOWN = 0, DATA_TYPE_INT16 = ( 1 << 0 ), DATA_TYPE_INT32 = ( 1 << 1 ), DATA_TYPE_INT64 = ( 1 << 2 ),
  DATA_TYPE_FLOAT32 = ( 1 << 3 ), DATA_TYPE_FLOAT64 = ( 1 << 4 ), DATA_TYPE_COMPLEX32, DATA_TYPE_UINT32 = ( 1 << 6 )
}
 Defines the internal data representation. More...
 
typedef double sample_rate_type
 Defines the sample rate type.
 
typedef float signal_gain_type
 Defines the gain type.
 
typedef float signal_slope_type
 Defines the slope type.
 
typedef float signal_offset_type
 Defines the offset type.
 
typedef size_t size_type
 Defines sizes when dealing with channels.
 
typedef std::vector< std::string > channel_names_type
 A vector of channel names.
 

Public Member Functions

DLL_EXPORT buffer ()
 Default constructor. More...
 
DLL_EXPORT buffer (const channel &ChannelInfo, gps_second_type Second, gps_nanosecond_type NanoSecond, const void *Buffer, size_type BufferSize)
 Constructor. More...
 
DLL_EXPORT buffer (const channel &ChannelInfo, gps_second_type Second, gps_nanosecond_type NanoSecond, data_type &&Buffer)
 Constructor. More...
 
DLL_EXPORT size_type Samples () const
 Retrieve the number of samples being stored. More...
 
DLL_EXPORT gps_second_type Start () const
 Retrieve the GPS start second of the data. More...
 
DLL_EXPORT gps_nanosecond_type StartNano () const
 Retrieve the GPS start nano second of the data. More...
 
DLL_EXPORT gps_second_type Stop () const
 Retrieve the GPS stop second of the data. More...
 
DLL_EXPORT gps_nanosecond_type StopNano () const
 Retrieve the GPS stop nanosecond of the data. More...
 
DLL_EXPORT void swap (buffer &Source)
 Exchange the contents of this container with another.
 
DLL_EXPORT void resize (size_type N)
 Resize the container to hold N elements. More...
 
template<typename T >
const T * cbegin () const
 Return a constant data iterator for this buffer, that references the beginning of the data. More...
 
template<typename T >
const T * cend () const
 Return a constant data iterator for this buffer, that references the just after the end of the data. More...
 
template<typename T >
const T & at (size_type index) const
 This is a type aware, bounds checked lookup in the buffer. More...
 
DLL_EXPORT gps_second_type samples_to_seconds (size_type offset_samples) const
 Convert relative sample offsets to relative second offsets. More...
 
DLL_EXPORT gps_second_type samples_to_trailing_nanoseconds (size_type offset_samples) const
 Given a sample count, determine how many seconds and nanoseconds worth of data are avaialble, and return the nanosecond count. More...
 
DLL_EXPORT size_type bytes_to_samples (size_type offset_bytes) const
 Convert relative byte offsets to relative sample offsets. More...
 
DLL_EXPORT size_type seconds_to_samples (gps_second_type offset_seconds, gps_nanosecond_type offset_nano=0) const
 Convert relative second offsets to relative sample offsets. More...
 
DLL_EXPORT size_type samples_to_bytes (size_type offset_samples) const
 Convert relative sample offsets to relative byte offsets. More...
 
DLL_EXPORT void reset_channel_info (const channel &ChannelInfo, gps_second_type Second, gps_nanosecond_type NanoSecond)
 Reset the channel type. Set the sample count to 0. More...
 
- Public Member Functions inherited from NDS::abi_0::channel
DLL_EXPORT channel ()
 Default constructor. More...
 
DLL_EXPORT channel (const channel &Source)
 Copy constructor. More...
 
DLL_EXPORT channel (const std::string &Name, channel_type Type, data_type DataType, sample_rate_type SampleRate, signal_gain_type Gain, signal_slope_type Slope, signal_offset_type Offset, std::string Units)
 Create a channel object. More...
 
DLL_EXPORT const std::string & Name () const
 Return the channel name. More...
 
DLL_EXPORT std::string NameLong () const
 Return the name with additional information. More...
 
DLL_EXPORT channel_type Type () const
 Return the type of the channel. More...
 
DLL_EXPORT data_type DataType () const
 Return the data type of the channel. More...
 
DLL_EXPORT size_type DataTypeSize () const
 Return the size in bytes of an individual sample from the channel. More...
 
DLL_EXPORT sample_rate_type SampleRate () const
 Return the sample rate of the channel. More...
 
DLL_EXPORT signal_gain_type Gain () const
 Return the gain of the channel. More...
 
DLL_EXPORT signal_slope_type Slope () const
 Return the slope of the channel. More...
 
DLL_EXPORT signal_offset_type Offset () const
 Return the offset of the channel. More...
 
DLL_EXPORT const std::string & Units () const
 Return the units of this channel. More...
 
DLL_EXPORT void swap (channel &Source)
 Swap this channel with another. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from NDS::abi_0::channel
static DLL_EXPORT channel_type convert_daq_chantype (int ChanType)
 Convert from the legacy daqd channel types to a channel_type enum. More...
 
static DLL_EXPORT data_type convert_daq_datatype (int DataType)
 Convert from the legacy daqd data types to a data_type enum. More...
 
static DLL_EXPORT const
std::string & 
ToString (channel_type ChannelType)
 Return a string representatino of the given channel_type. More...
 
static DLL_EXPORT const
std::string & 
ToString (data_type DataType)
 Return a string representatino of the given data_type. More...
 
static DLL_EXPORT bool IsSecondTrend (const std::string &Name)
 Check the channel name to see if it is a second trend. More...
 
static DLL_EXPORT bool IsMinuteTrend (const std::string &Name)
 Check the channel name to see if it is a minute trend. More...
 
- Static Public Attributes inherited from NDS::abi_0::channel
static DLL_EXPORT const
channel_type 
DEFAULT_CHANNEL_MASK
 The combination of all valid channel types.
 
static DLL_EXPORT const data_type DEFAULT_DATA_MASK
 The combinatino of all valid data types.
 
static DLL_EXPORT const
sample_rate_type 
MIN_SAMPLE_RATE = 0.0f
 Smallest sample rate possible.
 
static DLL_EXPORT const
sample_rate_type 
MAX_SAMPLE_RATE = 1e12f
 Largest sample rate possible.
 

Detailed Description

A buffer holds the data contents of a channel.

This class facilitates the storage of data and accompanying meta data.

Constructor & Destructor Documentation

NDS::abi_0::buffer::buffer ( )

Default constructor.

Returns
New object instance
NDS::abi_0::buffer::buffer ( const channel ChannelInfo,
gps_second_type  Second,
gps_nanosecond_type  NanoSecond,
const void *  Buffer,
size_type  BufferSize 
)

Constructor.

Parameters
[in]ChannelInfoChannel metadata.
[in]SecondGPS second start time of channel data.
[in]NanoSecondGPS nanosecond start time of channel data.
[in]BufferChannel data.
[in]BufferSizeNumber of bytes in Buffer.
Returns
New object instance
NDS::abi_0::buffer::buffer ( const channel ChannelInfo,
gps_second_type  Second,
gps_nanosecond_type  NanoSecond,
data_type &&  Buffer 
)

Constructor.

Parameters
[in]ChannelInfoChannel metadata.
[in]SecondGPS second start time of channel data.
[in]NanoSecondGPS nanosecond start time of channel data.
[in]BufferChannel data in a std::vector<char>. The vector will be moved from.
Returns
New object instance

Member Function Documentation

template<typename T >
const T& NDS::abi_0::buffer::at ( size_type  index) const
inline

This is a type aware, bounds checked lookup in the buffer.

Template Parameters
TThe type to return a const reference for.
indexThe number/index of the sample to reference.
Returns
A const reference to the sample.
Note
If T is incompatible with the runtime type of the buffer an exception is thrown. If the index is out of bounds < 0 || >= Samples() an out of range exception is thrown.
buffer::size_type NDS::abi_0::buffer::bytes_to_samples ( buffer::size_type  offset_bytes) const
inline

Convert relative byte offsets to relative sample offsets.

Parameters
[in]offset_bytesAn byte number [0,...)
Returns
The number of samples since the beginning of this buffer that
template<typename T >
const T* NDS::abi_0::buffer::cbegin ( ) const
inline

Return a constant data iterator for this buffer, that references the beginning of the data.

Template Parameters
TThe type to return an iterator for
Returns
The iterator
Note
If T is incompatible with the runtime type of the buffer an exception is thrown. If T is void a void pointer to the buffer is returned, and you are guaranted not to have an exception raised.
template<typename T >
const T* NDS::abi_0::buffer::cend ( ) const
inline

Return a constant data iterator for this buffer, that references the just after the end of the data.

Template Parameters
TThe type to return an iterator for
Returns
The iterator
Note
If T is incompatible with the runtime type of the buffer an exception is thrown.
void NDS::abi_0::buffer::reset_channel_info ( const channel ChannelInfo,
gps_second_type  Second,
gps_nanosecond_type  NanoSecond 
)

Reset the channel type. Set the sample count to 0.

Parameters
[in]ChannelInfochannel meta data to copy into this buffer
[in]SecondA second number [0,...) that the buffer should start at
[in]NanoSecondThe number of nanoseconds atfer Second that this buffer starts.
Returns
The number of samples since the beginning of this buffer that this time location refers to.
void NDS::abi_0::buffer::resize ( size_type  N)
inline

Resize the container to hold N elements.

Parameters
[in]NThe new number of elements to be stored.
buffer::size_type NDS::abi_0::buffer::Samples ( ) const
inline

Retrieve the number of samples being stored.

Returns
The number of samples being stored

The number of samples in the data set. The number of bytes stored is the number of samples multiplied by size of the data type.

buffer::size_type NDS::abi_0::buffer::samples_to_bytes ( buffer::size_type  offset_samples) const
inline

Convert relative sample offsets to relative byte offsets.

Parameters
[in]offset_samplesA sample number [0,...). This is the number of samples since the start of this buffer
Returns
The byte offset that this sample would refer to relative to the start of this buffer.
buffer::gps_second_type NDS::abi_0::buffer::samples_to_seconds ( buffer::size_type  offset_samples) const
inline

Convert relative sample offsets to relative second offsets.

Parameters
[in]offset_samplesAn sample number [0,...)
Returns
The number of seconds since the beginning of this buffer that this sample refers located at. This is the number of seconds since Start().
buffer::gps_nanosecond_type NDS::abi_0::buffer::samples_to_trailing_nanoseconds ( size_type  offset_samples) const
inline

Given a sample count, determine how many seconds and nanoseconds worth of data are avaialble, and return the nanosecond count.

Parameters
[in]offset_samplesAn sample number [0,...)
Returns
A nanosecond value [0,1000000000) corresponding to the number of nanoseconds passed the last second boundary for a given sample count.
buffer::size_type NDS::abi_0::buffer::seconds_to_samples ( buffer::gps_second_type  offset_seconds,
buffer::gps_nanosecond_type  offset_nano = 0 
) const
inline

Convert relative second offsets to relative sample offsets.

Parameters
[in]offset_secondsA second number [0,...). This is the number of seconds since Start()
[in]offset_nanoA nanosecond offset, defaults to 0
Returns
The number of samples since the beginning of this buffer that
buffer::gps_second_type NDS::abi_0::buffer::Start ( ) const
inline

Retrieve the GPS start second of the data.

Returns
The GPS start second of the data
buffer::gps_nanosecond_type NDS::abi_0::buffer::StartNano ( ) const
inline

Retrieve the GPS start nano second of the data.

Returns
The GPS start nano second of the data
buffer::gps_second_type NDS::abi_0::buffer::Stop ( ) const
inline

Retrieve the GPS stop second of the data.

Returns
The GPS stop second of the data
buffer::gps_nanosecond_type NDS::abi_0::buffer::StopNano ( ) const
inline

Retrieve the GPS stop nanosecond of the data.

Returns
The GPS stop nanosecond of the data

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