DUECA/DUSIME
|
This can be used to read data from a stream channel. More...
#include <StreamAccessToken.hxx>
Public Member Functions | |
void | getAccess (const T *&data, const TimeSpec &ts) |
Makes the reference to the data valid, does not return the data's age. | |
void | getAccessToLatest (const T *&data, DataTimeSpec &ts) |
Get always the latest version of the data. | |
int | getNumWaitingSets () const |
Returns the number of data points available. | |
void | releaseAccess (const T *&data) |
Returns the read channel access pointer. | |
bool | amILagging (const TimeSpec &t) |
Determines whether the current process is behind in data reading. | |
bool | amILaggingMuch (const TimeSpec &t) |
Determine whether you are more than one cycle behind in reading the data. | |
int | getChannelDepth () |
Figure out how many data copies are configured. | |
StreamChannelReadToken (const GlobalId &holder, const NameSet &name_set, int ndc=11, Channel::TransportClass tclass=Channel::HighPriority, GenericCallback *when_valid=NULL) | |
Constructor. | |
~StreamChannelReadToken () | |
Destructor. | |
Public Member Functions inherited from dueca::ChannelReadToken | |
ChannelReadToken (const GlobalId &owner, const NameSet &channelname, const std::string &dataclassname, entryid_type entryhandle=0, Channel::EntryTimeAspect time_aspect=Channel::Continuous, Channel::EntryArity arity=Channel::OnlyOneEntry, Channel::ReadingMode rmode=Channel::AdaptEventStream, double requested_span=0.2, const UCallbackOrActivity &when_valid=UCallbackOrActivity()) | |
Constructor, creates a token and if needed creates the associated channel end. | |
ChannelReadToken (const GlobalId &owner, const NameSet &channelname, const std::string &dataclassname, entryid_type entryhandle, Channel::EntryTimeAspect time_aspect, Channel::EntryArity arity, Channel::ReadingMode rmode, double requested_span, Channel::TransportClass tclass, GenericCallback *when_valid=NULL) | |
ChannelReadToken constructor, deprecated version. | |
ChannelReadToken (const GlobalId &owner, const NameSet &channelname, const std::string &dataclassname, const std::string &entrylabel, Channel::EntryTimeAspect time_aspect=Channel::Continuous, Channel::EntryArity arity=Channel::OnlyOneEntry, Channel::ReadingMode rmode=Channel::AdaptEventStream, double requested_span=0.2, const UCallbackOrActivity &when_valid=UCallbackOrActivity()) | |
Constructor, creates a token and if needed creates the associated channel end. | |
ChannelReadToken (const GlobalId &owner, const NameSet &channelname, const std::string &dataclassname, const std::string &entrylabel, Channel::EntryTimeAspect time_aspect, Channel::EntryArity arity, Channel::ReadingMode rmode, double requested_span, Channel::TransportClass tclass, GenericCallback *when_valid=NULL) | |
ChannelReadToken constructor, deprecated version. | |
ChannelReadToken (const GlobalId &owner, const NameSet &channelname, const std::string &dataclassname, entryid_type entryhandle, Channel::EntryTimeAspect time_aspect, Channel::EntryArity arity, Channel::ReadingMode rmode, const UCallbackOrActivity &when_valid, unsigned requested_depth) | |
Constructor, creates a token and if needed creates the associated channel end. | |
bool | isValid () |
Check the validity of the token. | |
const GlobalId & | getClientId () const |
Return the client ID. | |
const GlobalId & | getChannelId () const |
Return the channel ID. | |
bool | isSequential () const |
Data access type, sequential? | |
Channel::EntryTimeAspect | getTimeAspect () const |
Time aspect of read data. | |
DataTimeSpec | getOldestDataTime () const |
Return the span of the oldest data in the current entry. | |
DataTimeSpec | getLatestDataTime () const |
Return the span of the latest data in the current entry. | |
void | selectFirstEntry () |
Instruct the token to start dealing with the first entry in the channel. | |
void | selectNextEntry () |
Instruct the token to start dealing with the next entry. | |
bool | haveEntry () const |
Check that there is a valid entry to read. | |
const entryid_type | getEntryId () const |
Get the entry handle id. | |
const std::string & | getEntryLabel () const |
Get the current entry's label, if available. | |
unsigned int | getNumVisibleSets (const TimeTickType ts=MAX_TIMETICK) const |
Returns the number of data points older than the given time. | |
unsigned int | getNumVisibleSets (const DataTimeSpec ts) const |
Returns the number of data points older than the given, for any of the entries read by this token. | |
unsigned int | getNumVisibleSetsInEntry (const TimeTickType ts=MAX_TIMETICK) const |
Returns the number of data points older than the given time for the currently selected entry read by this token. | |
unsigned int | getNumVisibleSetsInEntry (const DataTimeSpec ts) const |
Returns the number of data points older than the given time, for the currently selected entry read by this token. | |
bool | haveVisibleSets (const TimeTickType ts=MAX_TIMETICK) const |
Returns true if there are data points visible at the given time, for any of the entries read by this token. | |
bool | haveVisibleSets (const DataTimeSpec ts) const |
Returns true if there are data points visible at the given time. | |
bool | haveVisibleSetsInEntry (const TimeTickType ts=MAX_TIMETICK) const |
Returns true if there are data points visible at the given time, for the current entry read by this token. | |
bool | haveVisibleSetsInEntry (const DataTimeSpec ts) const |
Returns true if there are data points visible at the given time, for the current entry read by this token. | |
unsigned int | flushTotalAvailableSets () const |
Flush all data in a channel for this reader. | |
unsigned int | flushOlderSets () const |
Flush almost all data in a channel for this reader, but leave one dataset in. | |
unsigned int | flushOlderSets (const TimeTickType ts) const |
Flush almost all data in a channel for this reader, but leave datasets newer than ts. | |
unsigned int | flushOne () const |
Flush a single dataset for this reader. | |
ChannelEntryInfo | getChannelEntryInfo () const |
Retrieve creation/entry information. | |
AccessResult | readAndStoreData (AmorphStore &s, TimeTickType &tsprev) |
Read channel data into an amorph store object. | |
bool | readAndPack (AmorphStore &s, DataTimeSpec &ts, const TimeSpec &tsreq=TimeSpec(0U, MAX_TIMETICK)) |
Read channel data into an amorph store object. | |
~ChannelReadToken () | |
Destructor. | |
bool | applyFunctor (DCOFunctor *fnct, TimeTickType time=MAX_TIMETICK) |
Apply a given functor to channel data. | |
Public Member Functions inherited from dueca::GenericToken | |
const GlobalId & | getTokenHolder () const |
Return the ID of the owner. | |
const GlobalId & | getChannelId () const |
Return the ID of the channel. | |
const NameSet & | getName () const |
Return the local name specified for the token. | |
const std::string & | getDataClassName () const |
Return the data class name. | |
uint32_t | getDataClassMagic () const |
Access the data class magic. | |
virtual | ~GenericToken () |
Destructor. | |
GenericToken (const GlobalId &holder, const NameSet &name, const std::string &dataclassname) | |
Constructor. | |
template<class MFT > | |
std::weak_ptr< MFT > | getMetaFunctor (const std::string &fname) const |
Obtain a specific metafunctor for interaction with channel data. | |
Public Member Functions inherited from dueca::TriggerPuller | |
const std::string & | getTriggerName () const |
Find a name. | |
Additional Inherited Members | |
Public Types inherited from dueca::ChannelReadToken | |
enum | AccessResult { NoData , TimeSkip , DataSuccess } |
Different type of access result. More... | |
Protected Types inherited from dueca::TriggerPuller | |
typedef list< TargetData > | targetlist_type |
Combination of a target, someone to pull if requested, and the index that target needs to identify this puller. | |
Protected Member Functions inherited from dueca::ChannelReadToken | |
const void * | getAccess (TimeTickType t_request, DataTimeSpec &ts, GlobalId &origin, uint32_t magic) |
Return a void pointer to the data in the current entry. | |
void | releaseAccess (const void *data_ptr) |
Return the read access given previously. | |
void | releaseAccessKeepData (const void *data_ptr) |
Return the read access given previously, but keep the data. | |
void | addTarget (const boost::intrusive_ptr< TriggerTarget > &t, unsigned id) |
Override the addTarget method from the TriggerPuller class. | |
Protected Member Functions inherited from dueca::GenericToken | |
void | checkChannelEndPresent () const |
Check preconditions. | |
Protected Member Functions inherited from dueca::TriggerPuller | |
void | pull (const DataTimeSpec &ts) |
activate and notify the targets | |
TriggerPuller (const std::string &name=std::string()) | |
Constructor. | |
virtual | ~TriggerPuller () |
Destructor. | |
virtual void | removeTarget (const TriggerTarget *target) |
Remove a target from the puller, only called by destructor. | |
virtual void | setTriggerName () |
Update the name, used by ConditionAnd and ConditionOr. | |
Protected Attributes inherited from dueca::GenericToken | |
std::string | dataclassname |
name of the data type | |
const DataSetConverter * | converter |
Converter for the data. | |
uint32_t | magic_number |
magic number for the data class name claimed here | |
UnifiedChannel * | channel |
pointer to the channel | |
Protected Attributes inherited from dueca::TriggerPuller | |
targetlist_type | targets |
List of targets and indices. | |
std::bitset< MAX_MANAGERS > | activitylevels |
Index of activitymanager levels. | |
std::string | name |
Name, for debugging purposes. | |
This can be used to read data from a stream channel.
The access token objects are used in conjunction with the channel system. When a component requests access to a channel, an access token is created and returned to the component.
For the component, the accessToken acts as a key. Using the accessToken on the channel, access to the data on the channel can be got.
For the channel, the accessToken acts as an identifier. It contains the sequence number of the component, as used in the channel object, and a GlobalId of the component. These are used for accounting purposes.
Note that StreamChannelReadToken is obsolete; please use ChannelReadToken in new code.
dueca::StreamChannelReadToken< T >::StreamChannelReadToken | ( | const GlobalId & | holder, |
const NameSet & | name_set, | ||
int | ndc = 11, | ||
Channel::TransportClass | tclass = Channel::HighPriority, | ||
GenericCallback * | when_valid = NULL ) |
Constructor.
Constructs an access token to read the stream channel with the specified name.
holder | ID of the requester. |
name_set | NameSet with the name of the channel that you request access for. |
ndc | For older, legacy applications, this represented the number of data copies held in parallel in the channel. The first module to specify this called the shots. For compatibility, in DUECA 2.0 and above this is converted to a time span in seconds for the data in the channel, by multiplying the ndc value with 0.01, the assumed most common update interval. Currently the largest value specified in the local dueca node is used. |
tclass | Transport class for the channel. Current options are Regular and Bulk. Bulk is really not recommended for stream channels. |
when_valid | Callback called when the token becomes valid. |
Destructor.
The existence of the channel may continue, it is really destroyed when you were the last user.
Makes the reference to the data valid, does not return the data's age.
As a side effect the access to the data is registered.
data | Pointer will be pointing to data afterward. |
ts | Time for which access is requested. |
void dueca::StreamChannelReadToken< T >::getAccessToLatest | ( | const T *& | data, |
DataTimeSpec & | ts ) |
Get always the latest version of the data.
Use this only in special applications, e.g. for projection on interfaces etc.
data | Pointer will be pointing to data afterward. |
ts | Time for which access is requested. |
Returns the read channel access pointer.
The data access registration is undone.
Determines whether the current process is behind in data reading.
For if you can afford to skip.
Determine whether you are more than one cycle behind in reading the data.
int dueca::StreamChannelReadToken< T >::getChannelDepth | ( | ) |
Figure out how many data copies are configured.
Note that while there is no writer for this channel, the channel will not be prepared, and this function will return 0.