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

This can be used to read data from a stream channel. More...

#include <StreamAccessToken.hxx>

Inheritance diagram for dueca::StreamChannelReadToken< T >:
Inheritance graph
[legend]
Collaboration diagram for dueca::StreamChannelReadToken< T >:
Collaboration graph
[legend]

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 GlobalIdgetClientId () const
 Return the client ID.
 
const GlobalIdgetChannelId () 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 GlobalIdgetTokenHolder () const
 Return the ID of the owner.
 
const GlobalIdgetChannelId () const
 Return the ID of the channel.
 
const NameSetgetName () 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< MFTgetMetaFunctor (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< TargetDatatargetlist_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 voidgetAccess (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 DataSetConverterconverter
 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_MANAGERSactivitylevels
 Index of activitymanager levels.
 
std::string name
 Name, for debugging purposes.
 

Detailed Description

template<class T>
class dueca::StreamChannelReadToken< T >

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.

Constructor & Destructor Documentation

◆ StreamChannelReadToken()

template<class T >
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.

Parameters
holderID of the requester.
name_setNameSet with the name of the channel that you request access for.
ndcFor 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.
tclassTransport class for the channel. Current options are Regular and Bulk. Bulk is really not recommended for stream channels.
when_validCallback called when the token becomes valid.

◆ ~StreamChannelReadToken()

Destructor.

The existence of the channel may continue, it is really destroyed when you were the last user.

Member Function Documentation

◆ getAccess()

template<class T >
void dueca::StreamChannelReadToken< T >::getAccess ( const T *& data,
const TimeSpec & ts )

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.

Deprecated
As of July 2001, this call is deprecated. Use a StreamReader instead!
Parameters
dataPointer will be pointing to data afterward.
tsTime for which access is requested.

◆ getAccessToLatest()

template<class T >
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.

Parameters
dataPointer will be pointing to data afterward.
tsTime for which access is requested.
Deprecated
As of july 2001, this call is deprecated. Use a StreamReaderLatest instead!

◆ releaseAccess()

template<class T >
void dueca::StreamChannelReadToken< T >::releaseAccess ( const T *& data)

Returns the read channel access pointer.

The data access registration is undone.

Deprecated
As of july 2001, this call is deprecated. Use a StreamReader or StreamReaderLatest instead!

◆ amILagging()

template<class T >
bool dueca::StreamChannelReadToken< T >::amILagging ( const TimeSpec & t)

Determines whether the current process is behind in data reading.

For if you can afford to skip.

Deprecated
Using this function produces more or less random results when triggering on multiple channels. Use the noScheduledBehind() function on the Activity instead.

◆ amILaggingMuch()

template<class T >
bool dueca::StreamChannelReadToken< T >::amILaggingMuch ( const TimeSpec & t)

Determine whether you are more than one cycle behind in reading the data.

Deprecated
Using this function produces more or less random results when triggering on multiple channels. Use the noScheduledBehind() function on the Activity instead.

◆ getChannelDepth()

template<class T >
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.

Returns
"Depth" of a channel, i.e. how many data copies it remembers.

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