3 #ifndef SWIG__COMMON__NDS_BUFFER_HH
4 #define SWIG__COMMON__NDS_BUFFER_HH
11 #include "nds_export.hh"
12 #include "nds_channel.hh"
17 inline namespace abi_0
168 template <
typename T >
172 const auto val_type =
173 NDS::channel_data_type_conversion< T >::value;
176 ( std::is_same< T, void >::value &&
177 val_type == NDS::channel::DATA_TYPE_UNKNOWN ) )
179 return reinterpret_cast< const T*
>( data.data( ) );
181 throw std::runtime_error(
182 "Invalid cast, the buffer data type is "
183 "not compatible with your requested "
195 template <
typename T >
199 const auto val_type =
200 NDS::channel_data_type_conversion< T >::value;
203 ( std::is_same< T, void >::value &&
204 val_type == NDS::channel::DATA_TYPE_UNKNOWN ) )
206 return reinterpret_cast< const T*
>(
209 throw std::runtime_error(
210 "Invalid cast, the buffer data type is "
211 "not compatible with your requested "
225 template <
typename T >
229 const T* start = cbegin< T >( );
230 if ( array_out_of_range( index,
Samples( ) ) )
232 throw std::out_of_range(
233 "The requested index is out of range" );
235 return start[ index ];
349 template <
typename IndexType >
350 bool array_out_of_range( IndexType Index, IndexType Max )
const;
353 bool is_minute_trend( )
const;
356 typedef std::vector< buffer > buffers_type;
359 buffer::is_minute_trend( )
const
369 if ( is_minute_trend( ) )
381 NDS::buffer::size_type offset_samples )
const
383 if ( is_minute_trend( ) )
408 if ( is_minute_trend( ) )
410 return static_cast< size_type >( offset_seconds / 60 );
447 return gps_nanosecond;
462 additional_from_nano;
471 return total_ns % 1000000000;
485 DLL_EXPORT
extern std::ostream& operator<<( std::ostream& os,
488 DLL_EXPORT
extern std::ostream& operator<<( std::ostream& os,
489 const buffers_type& obj );
496 buffer::array_out_of_range< size_t >(
size_t Index,
size_t Max )
const
498 return ( Index >= Samples( ) );
501 template <
typename IndexType >
503 buffer::array_out_of_range( IndexType Index, IndexType Max )
const
505 return ( Index <= 0 || Index >=
Samples( ) );
const T * cbegin() const
Return a constant data iterator for this buffer, that references the beginning of the data...
Definition: nds_buffer.hh:170
DLL_EXPORT size_type bytes_to_samples(size_type offset_bytes) const
Convert relative byte offsets to relative sample offsets.
Definition: nds_buffer.hh:396
Minute trend.
Definition: nds_channel.hh:45
A buffer holds the data contents of a channel.
Definition: nds_buffer.hh:27
DLL_EXPORT gps_second_type Start() const
Retrieve the GPS start second of the data.
Definition: nds_buffer.hh:437
DLL_EXPORT data_type DataType() const
Return the data type of the channel.
Definition: nds_channel.hh:319
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.
Definition: nds_buffer.hh:404
DLL_EXPORT size_type DataTypeSize() const
Return the size in bytes of an individual sample from the channel.
Definition: nds_channel.hh:325
long gps_nanosecond_type
Type nano second portion of a gps time.
Definition: nds_buffer.hh:37
size_t size_type
Type appropriate for length.
Definition: nds_buffer.hh:41
DLL_EXPORT gps_nanosecond_type StopNano() const
Retrieve the GPS stop nanosecond of the data.
Definition: nds_buffer.hh:466
DLL_EXPORT gps_second_type samples_to_seconds(size_type offset_samples) const
Convert relative sample offsets to relative second offsets.
Definition: nds_buffer.hh:367
long gps_second_type
Type second portion of a gps time.
Definition: nds_buffer.hh:33
const T & at(size_type index) const
This is a type aware, bounds checked lookup in the buffer.
Definition: nds_buffer.hh:227
DLL_EXPORT gps_nanosecond_type StartNano() const
Retrieve the GPS start nano second of the data.
Definition: nds_buffer.hh:445
DLL_EXPORT size_type Samples() const
Retrieve the number of samples being stored.
Definition: nds_buffer.hh:429
DLL_EXPORT size_type samples_to_bytes(size_type offset_samples) const
Convert relative sample offsets to relative byte offsets.
Definition: nds_buffer.hh:418
DLL_EXPORT void resize(size_type N)
Resize the container to hold N elements.
Definition: nds_buffer.hh:477
DLL_EXPORT sample_rate_type SampleRate() const
Return the sample rate of the channel.
Definition: nds_channel.hh:348
DLL_EXPORT buffer()
Default constructor.
Definition: nds_buffer.cc:12
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...
Definition: nds_buffer.hh:380
DLL_EXPORT gps_second_type Stop() const
Retrieve the GPS stop second of the data.
Definition: nds_buffer.hh:453
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.
Definition: nds_buffer.cc:64
const T * cend() const
Return a constant data iterator for this buffer, that references the just after the end of the data...
Definition: nds_buffer.hh:197
Represents a LIGO data channel.
Definition: nds_channel.hh:33
data_type
Defines the internal data representation.
Definition: nds_channel.hh:53
DLL_EXPORT void swap(buffer &Source)
Exchange the contents of this container with another.
Definition: nds_buffer.cc:46
DLL_EXPORT channel_type Type() const
Return the type of the channel.
Definition: nds_channel.hh:313
std::vector< unsigned char > data_type
Storage type for the data.
Definition: nds_buffer.hh:45