ChimeraTK-DeviceAccess  03.18.00
ChimeraTK::ReadAnyGroup Class Reference

Group several registers (= TransferElement) to allow waiting for an update of any of the registers. More...

#include <ReadAnyGroup.h>

Classes

class  Notification
 Notification object returned by waitAny(). More...
 

Public Member Functions

 ReadAnyGroup ()
 Construct empty group. More...
 
 ReadAnyGroup (std::initializer_list< std::reference_wrapper< TransferElementAbstractor >> list)
 Construct finalised group with the given elements. More...
 
 ReadAnyGroup (std::initializer_list< boost::shared_ptr< TransferElement >> list)
 Construct finalised group with the given elements. More...
 
template<typename ITERATOR >
 ReadAnyGroup (ITERATOR first, ITERATOR last)
 Construct finalised group with the given elements. More...
 
void add (TransferElementAbstractor &element)
 Add register to group. More...
 
void add (boost::shared_ptr< TransferElement > element)
 See the other signature of add(). More...
 
void finalise ()
 Finalise the group. More...
 
TransferElementID readAny ()
 Wait until one of the elements in this group has received an update. More...
 
TransferElementID readAnyNonBlocking ()
 Read the next available update in the group, but do not block if no update is available. More...
 
void readUntil (const TransferElementID &id)
 Wait until the given TransferElement has received an update and store it to its user buffer. More...
 
void readUntil (const TransferElementAbstractor &element)
 See the other signature of readUntil(). More...
 
void readUntilAll (const std::vector< TransferElementID > &ids)
 Wait until all of the given TransferElements has received an update and store it to its user buffer. More...
 
void readUntilAll (const std::vector< TransferElementAbstractor > &elements)
 See the other signature of readUntilAll(). More...
 
Notification waitAny ()
 Wait until one of the elements received an update notification, but do not actually process the updated value yet. More...
 
Notification waitAnyNonBlocking ()
 Check if an update is available in the group, but do not block if no update is available. More...
 
void processPolled ()
 Process polled transfer elements (update them if new values are available). More...
 
void interrupt ()
 Convenience function to interrupt any running readAny/waitAny by calling interrupt on one of the push-type TransferElements in the group. More...
 

Detailed Description

Group several registers (= TransferElement) to allow waiting for an update of any of the registers.

After the group has been finalised (cf. ReadAnyGroup::finalise), read functions may no longer be called directly on the participating elements.

Definition at line 21 of file ReadAnyGroup.h.

Constructor & Destructor Documentation

◆ ReadAnyGroup() [1/4]

ChimeraTK::ReadAnyGroup::ReadAnyGroup ( )
inlinedefault

Construct empty group.

Elements can later be added using the add() function, or by copying another object.

◆ ReadAnyGroup() [2/4]

ChimeraTK::ReadAnyGroup::ReadAnyGroup ( std::initializer_list< std::reference_wrapper< TransferElementAbstractor >>  list)
inline

Construct finalised group with the given elements.

The group will behave like finalise() had already been called.

Definition at line 424 of file ReadAnyGroup.h.

+ Here is the call graph for this function:

◆ ReadAnyGroup() [3/4]

ChimeraTK::ReadAnyGroup::ReadAnyGroup ( std::initializer_list< boost::shared_ptr< TransferElement >>  list)
inline

Construct finalised group with the given elements.

The group will behave like finalise() had already been called.

Definition at line 431 of file ReadAnyGroup.h.

+ Here is the call graph for this function:

◆ ReadAnyGroup() [4/4]

template<typename ITERATOR >
ChimeraTK::ReadAnyGroup::ReadAnyGroup ( ITERATOR  first,
ITERATOR  last 
)

Construct finalised group with the given elements.

The group will behave like finalise() had already been called.

Definition at line 439 of file ReadAnyGroup.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ add() [1/2]

void ChimeraTK::ReadAnyGroup::add ( boost::shared_ptr< TransferElement element)
inline

See the other signature of add().

Definition at line 471 of file ReadAnyGroup.h.

+ Here is the call graph for this function:

◆ add() [2/2]

void ChimeraTK::ReadAnyGroup::add ( TransferElementAbstractor element)
inline

Add register to group.

Note that calling this function is only allowed before finalise() has been called. The given register may not yet be part of a ReadAnyGroup or a TransferGroup, otherwise an exception is thrown.

The register must be must be readable. Note, we disallow adding const-refs to TransferElement(Abtractor)s. TransferElements added to the group change in behaviour, since their underlying future_queues are modified (in order to notify the ReadAny future queue).

Definition at line 446 of file ReadAnyGroup.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ finalise()

void ChimeraTK::ReadAnyGroup::finalise ( )
inline

Finalise the group.

From this point on, add() may no longer be called. Only after the group has been finalised the read functions of this group may be called. Also, after the group has been finalised, read functions may no longer be called directly on the participating elements (including other copies of the same element).

The order of update notifications will only be well-defined for updates which happen after the call to finalise(). Any unread values which are present in the TransferElements when this function is called will not be processed in the correct sequence. Only the sequence within each TransferElement can be guaranteed. For any updates which arrive after the call to finalise() the correct sequence will be guaranteed even accross TransferElements.

This function will call readAsync() on all elements with AccessMode::wait_for_new_data in the group. There must be at least one transfer element with AccessMode::wait_for_new_data in the group, otherwise an exception is thrown.

Definition at line 478 of file ReadAnyGroup.h.

+ Here is the caller graph for this function:

◆ interrupt()

void ChimeraTK::ReadAnyGroup::interrupt ( )
inline

Convenience function to interrupt any running readAny/waitAny by calling interrupt on one of the push-type TransferElements in the group.

Definition at line 272 of file ReadAnyGroup.h.

◆ processPolled()

void ChimeraTK::ReadAnyGroup::processPolled ( )
inline

Process polled transfer elements (update them if new values are available).

Before calling this function, finalise() must have been called, otherwise the behaviour is undefined.

Definition at line 620 of file ReadAnyGroup.h.

+ Here is the caller graph for this function:

◆ readAny()

TransferElementID ChimeraTK::ReadAnyGroup::readAny ( )
inline

Wait until one of the elements in this group has received an update.

The function will return the TransferElementID of the element which has received the update. If multiple updates are received at the same time or if multiple updates were already present before the call to this function, the ID of the first element receiving an update will be returned.

Only elements with AccessMode::wait_for_new_data are used for waiting. Once an update has been received for one of these elements, the function will call readLatest() on all elements without AccessMode::wait_for_new_data (this is equivalent to calling processPolled()).

Before returning, the postRead action will be called on the TransferElement whose ID is returned, so the read data will already be present in the user buffer. All other TransferElements in this group will not be altered.

Before calling this function, finalise() must have been called, otherwise the behaviour is undefined.

Definition at line 498 of file ReadAnyGroup.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readAnyNonBlocking()

TransferElementID ChimeraTK::ReadAnyGroup::readAnyNonBlocking ( )
inline

Read the next available update in the group, but do not block if no update is available.

If no update is available, a default-constructed TransferElementID is returned after all poll-type elements in the group have been updated.

Before calling this function, finalise() must have been called, otherwise the behaviour is undefined.

Definition at line 511 of file ReadAnyGroup.h.

+ Here is the call graph for this function:

◆ readUntil() [1/2]

void ChimeraTK::ReadAnyGroup::readUntil ( const TransferElementAbstractor element)
inline

See the other signature of readUntil().

Definition at line 638 of file ReadAnyGroup.h.

+ Here is the call graph for this function:

◆ readUntil() [2/2]

void ChimeraTK::ReadAnyGroup::readUntil ( const TransferElementID id)
inline

Wait until the given TransferElement has received an update and store it to its user buffer.

All updates of other elements which are received before the update of the given element will be processed and are thus visible in the user buffers when this function returns.

The specified TransferElement must be part of this ReadAnyGroup, otherwise the behaviour is undefined.

This is merely a convenience function calling waitAny() in a loop until the ID of the given element is returned.

Before calling this function, finalise() must have been called, otherwise the behaviour is undefined.

Definition at line 629 of file ReadAnyGroup.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readUntilAll() [1/2]

void ChimeraTK::ReadAnyGroup::readUntilAll ( const std::vector< TransferElementAbstractor > &  elements)
inline

See the other signature of readUntilAll().

Definition at line 663 of file ReadAnyGroup.h.

+ Here is the call graph for this function:

◆ readUntilAll() [2/2]

void ChimeraTK::ReadAnyGroup::readUntilAll ( const std::vector< TransferElementID > &  ids)
inline

Wait until all of the given TransferElements has received an update and store it to its user buffer.

All updates of other elements which are received before the update of the given element will be processed and are thus visible in the user buffers when this function returns.

The specified TransferElement must be part of this ReadAnyGroup, otherwise the behaviour is undefined.

This is merely a convenience function calling waitAny() in a loop until the ID of the given element is returned.

Before calling this function, finalise() must have been called, otherwise the behaviour is undefined.

Definition at line 644 of file ReadAnyGroup.h.

+ Here is the call graph for this function:

◆ waitAny()

ReadAnyGroup::Notification ChimeraTK::ReadAnyGroup::waitAny ( )
inline

Wait until one of the elements received an update notification, but do not actually process the updated value yet.

This is similar to readAny() but the caller has to call accept() on the returned object manually. Also the poll-type elements in the group are not updated in this function.

This allows e.g. to acquire a lock before executing accept().

Before calling this function, finalise() must have been called, otherwise the behaviour is undefined.

The returned Notification object is only valid as long as the ReadAnyGroup still exists.

Definition at line 550 of file ReadAnyGroup.h.

+ Here is the caller graph for this function:

◆ waitAnyNonBlocking()

ReadAnyGroup::Notification ChimeraTK::ReadAnyGroup::waitAnyNonBlocking ( )
inline

Check if an update is available in the group, but do not block if no update is available.

If no update is available, an invalid Notification object is returned (i.e. Notification::isReady() will return false).

Before calling this function, finalise() must have been called, otherwise the behaviour is undefined.

The returned Notification object is only valid as long as the ReadAnyGroup still exists.

Definition at line 563 of file ReadAnyGroup.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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