DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dueca::DataReader< T, S > Class Template Reference

Lightweight class for accessing data in a channel. More...

#include <DataReader.hxx>

Inheritance diagram for dueca::DataReader< T, S >:
Inheritance graph
[legend]
Collaboration diagram for dueca::DataReader< T, S >:
Collaboration graph
[legend]

Public Member Functions

 DataReader (ChannelReadToken &token, const DataTimeSpec &ts)
 Constructor.
 
 DataReader (ChannelReadToken &token, const TimeSpec &ts)
 Constructor with TimeSpec.
 
 DataReader (ChannelReadToken &token, TimeTickType ts=MAX_TIMETICK)
 Constructor with time tick.
 
const Tdata ()
 Access to the data.
 
const DataTimeSpectimeSpec ()
 Return the time specification of the data.
 
const GlobalIdorigin ()
 Return the origin.
 
 ~DataReader ()
 Destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from dueca::DataReaderBase
 DataReaderBase (ChannelReadToken &token, const DataTimeSpec &t_request)
 Constructor.
 
- Protected Attributes inherited from dueca::DataReaderBase
ChannelReadTokentoken
 Reference to the channel access token.
 
DataTimeSpec t_request
 Time span or point requested.
 
DataTimeSpec ts_data
 Time specification as realised.
 
GlobalId data_origin
 Data origin.
 
bool firstaccess
 First access flag.
 

Detailed Description

template<class T, template< class > class S = MatchIntervalStart>
class dueca::DataReader< T, S >

Lightweight class for accessing data in a channel.

The DataReader accesses the data in a channel. These objects should be created on the stack, and when they go out of scope, the access to the channel is released again.

Example:

{
cout << r.data() << endl;
} // out of scope, access to data in channel released again
const T & data()
Access to the data.
Definition DataReader.hxx:456
This is a "light weight object" that enables you to read the latest set of data on a StreamChannelEnd...
Definition StreamReaderLatest.hxx:43

Parameters:

Template Parameters
TClass of the data to be read.
SData time selector. Note that MatchIntervalStart is the default here.

The class of data to be read should match what you specified for your read access token.

A channel typically holds data for multiple times. Time selectors determine for what time the data is returned. Typical data time selectors are:

MatchIntervalStart.

Note that event data is returned if the time point for the event is on or before the start of your requested interval. When reading stream data (which has a validity interval), this may also straddle the start moment, and it reads eagerly, so the data may not stretch for the full interval that you requested.

MatchIntervalStartOrEarlier. If data is not available for the requested time, but older data is available, then that older data is returned. If you read event data with ReadAllData or equivalent in the token constructor, this specifier is not needed, you will always get the older data. If you want to read the latest stream data, you do need this.

VirtualJoin. Produces a combined reading of all entries in a channel, typically only selected for event data. Note that it might be necessary for channels with many entries and a higher frequency of data writing, to repeatedly try reading or flushing to prevent data buildup in the channel.

If you don't supply a second argument (the time) to the constructor, the default time that is taken is infinity future. When reading sequentially (event) data, this just gives you the next available data on the list. If you created a token with Channel::JumpToMatchTime (the default for stream data), and you simply want the latest data in the channel, you must use the MatchIntervalStartOrEarlier specifier.

Constructor & Destructor Documentation

◆ DataReader() [1/3]

template<class T , template< class > class S = MatchIntervalStart>
dueca::DataReader< T, S >::DataReader ( ChannelReadToken & token,
const DataTimeSpec & ts )
inline

Constructor.

Note that these objects are light-weight, and meant to be constructed (on the stack) and discarded.

Parameters
tokenRead token
tsTime specification. Exact interpretation depends on the S template parameter.

◆ DataReader() [2/3]

template<class T , template< class > class S = MatchIntervalStart>
dueca::DataReader< T, S >::DataReader ( ChannelReadToken & token,
const TimeSpec & ts )
inline

Constructor with TimeSpec.

Parameters
tokenRead token.
tsTime specification. Accessed data point will not be newer than ts.getValidityStart()

◆ DataReader() [3/3]

template<class T , template< class > class S = MatchIntervalStart>
dueca::DataReader< T, S >::DataReader ( ChannelReadToken & token,
TimeTickType ts = MAX_TIMETICK )
inline

Constructor with time tick.

Parameters
tokenRead token.
tsTime tick. Accessed data point will not be newer than the tick. Note that the default (not specifying this parameter) simply gives you the latest data in the channel, if JumpToMatchTime is selected for the read token.

◆ ~DataReader()

template<class T , template< class > class S = MatchIntervalStart>
dueca::DataReader< T, S >::~DataReader ( )
inline

Destructor.

Releases the access again with a token.

Member Function Documentation

◆ data()

template<class T , template< class > class S = MatchIntervalStart>
const T & dueca::DataReader< T, S >::data ( )
inline

Access to the data.

Note that the constructors are lazy. The getAccess() call will perform the actual access.


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