DUECA/DUSIME
|
Lightweight class for accessing data in a channel. More...
#include <DataReader.hxx>
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 T & | data () |
Access to the data. | |
const DataTimeSpec & | timeSpec () |
Return the time specification of the data. | |
const GlobalId & | origin () |
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 | |
ChannelReadToken & | token |
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. | |
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:
Parameters:
T | Class of the data to be read. |
S | Data 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:
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.
|
inline |
Constructor.
Note that these objects are light-weight, and meant to be constructed (on the stack) and discarded.
token | Read token |
ts | Time specification. Exact interpretation depends on the S template parameter. |
|
inline |
Constructor with TimeSpec.
token | Read token. |
ts | Time specification. Accessed data point will not be newer than ts.getValidityStart() |
|
inline |
Constructor with time tick.
token | Read token. |
ts | Time 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. |
|
inline |
Destructor.
Releases the access again with a token.
|
inline |
Access to the data.
Note that the constructors are lazy. The getAccess() call will perform the actual access.