DUECA/DUSIME
|
An EventChannelReadToken can be used to read data from an event channel. More...
#include <EventAccessToken.hxx>
Public Member Functions | |
EventChannelReadToken (const GlobalId &holder, const NameSet &name_set, const ChannelDistribution d=ChannelDistribution::NO_OPINION, const Channel::TransportClass tclass=Channel::Regular, GenericCallback *when_valid=NULL) | |
Constructor. | |
~EventChannelReadToken () | |
Destructor. | |
const Event< T > & | getNextEvent (const TimeSpec &t) |
Return a reference to the oldest unread (by this access token) event in the channel. | |
void | getNextEvent (const Event< T > *&event, const TimeSpec &ts) |
Returns a reference to the oldest non-read event in the channel. | |
int | getNumWaitingEvents (const TimeSpec &ts=TimeSpec::end_of_time) |
Returns the number of events waiting for the client indicated by this access token. | |
int | flushWaitingEvents () |
Flushes all the events in the channel waiting for the component with the access token. | |
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. | |
An EventChannelReadToken can be used to read data from an event channel.
Note that the EventChannelReadToken is obsolete, use ChannelReadToken in new code. It currently serves a wrapper for ChannelReadToken, maintaining compatibility with legacy DUECA 0.x code.
By constructing an access token (and keeping it!!), a module gains access to the event channel. Note that this creates the obligation to read out the events (with the getNextEvent call), otherwise the channel gets clogged.
Note that EventChannelReadToken is obsolete; please use ChannelReadToken in new code.
dueca::EventChannelReadToken< T >::EventChannelReadToken | ( | const GlobalId & | holder, |
const NameSet & | name_set, | ||
const ChannelDistribution | d = ChannelDistribution::NO_OPINION, | ||
const Channel::TransportClass | tclass = Channel::Regular, | ||
GenericCallback * | when_valid = NULL ) |
Constructor.
Constructs an access token to read the event channel with the specified name.
holder | ID of the requester. |
name_set | NameSet with the name of the channel that you request access for. |
d | Type of "distribution". NO_OPINION means that you don't want to change the distribution type. JOIN_MASTER means you create a channel of which you are the master, and multiple others can send. Be careful when triggering on this event channel and using JOIN_MASTER; the time specification for the triggering might not coincide with the time spec of the next read event; always read without time specification when using JOIN_MASTER. |
tclass | Transport class for the channel. Current options are Regular and Bulk. |
when_valid | Pointer to a callback function object that will be called as soon as the token becomes valid. |
Destructor.
Returns access to the channel. Any events in the channel are irrevocably lost to the module.
Return a reference to the oldest unread (by this access token) event in the channel.
References to the event before this one will no longer be accessible.
t | Time specification, returned event <= the time |
void dueca::EventChannelReadToken< T >::getNextEvent | ( | const Event< T > *& | event, |
const TimeSpec & | ts ) |
Returns a reference to the oldest non-read event in the channel.
The returned event happened at or before the end time of the time specification. The age of the event can be queried from the event data, so it will not be given here. The event before this one will no longer be accessible.
event | A pointer that will point to the event after the call. |
ts | Time for the event. Only events valid before or at the start of the ts period can be returned. |
int dueca::EventChannelReadToken< T >::getNumWaitingEvents | ( | const TimeSpec & | ts = TimeSpec::end_of_time | ) |
Returns the number of events waiting for the client indicated by this access token.
ts | Time specification. Only events valid at or before the start of the period specified in ts are counted. If you want all events, omit this parameter. |
int dueca::EventChannelReadToken< T >::flushWaitingEvents | ( | ) |
Flushes all the events in the channel waiting for the component with the access token.
Of course, you should not get an access token in the first place if you cannot handle the events.