ChimeraTK-DeviceAccess 03.20.00
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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.
 
 ReadAnyGroup (std::initializer_list< std::reference_wrapper< TransferElementAbstractor > > list)
 Construct finalised group with the given elements.
 
 ReadAnyGroup (std::initializer_list< boost::shared_ptr< TransferElement > > list)
 Construct finalised group with the given elements.
 
template<typename ITERATOR >
 ReadAnyGroup (ITERATOR first, ITERATOR last)
 Construct finalised group with the given elements.
 
void add (TransferElementAbstractor &element)
 Add register to group.
 
 ReadAnyGroup (const ReadAnyGroup &)=delete
 
 ReadAnyGroup (ReadAnyGroup &&other) noexcept
 
ReadAnyGroupoperator= (ReadAnyGroup &&other) noexcept
 
void add (boost::shared_ptr< TransferElement > element)
 See the other signature of add().
 
void finalise ()
 Finalise the group.
 
TransferElementID readAny ()
 Wait until one of the elements in this group has received an update.
 
TransferElementID readAnyNonBlocking ()
 Read the next available update in the group, but do not block if no update is available.
 
void readUntil (const TransferElementID &id)
 Wait until the given TransferElement has received an update and store it to its user buffer.
 
void readUntil (const TransferElementAbstractor &element)
 See the other signature of readUntil().
 
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.
 
void readUntilAll (const std::vector< TransferElementAbstractor > &elements)
 See the other signature of readUntilAll().
 
Notification waitAny ()
 Wait until one of the elements received an update notification, but do not actually process the updated value yet.
 
Notification waitAnyNonBlocking ()
 Check if an update is available in the group, but do not block if no update is available.
 
void processPolled ()
 Process polled transfer elements (update them if new values are available).
 
void interrupt ()
 Convenience function to interrupt any running readAny/waitAny by calling interrupt on one of the push-type TransferElements in the group.
 

Friends

class ChimeraTK::DataConsistencyGroupDetail::HistorizedMatcher
 

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 25 of file ReadAnyGroup.h.

Constructor & Destructor Documentation

◆ ReadAnyGroup() [1/6]

ChimeraTK::ReadAnyGroup::ReadAnyGroup ( )
inlinedefault

Construct empty group.

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

◆ ReadAnyGroup() [2/6]

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 435 of file ReadAnyGroup.h.

◆ ReadAnyGroup() [3/6]

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 442 of file ReadAnyGroup.h.

◆ ReadAnyGroup() [4/6]

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 450 of file ReadAnyGroup.h.

◆ ReadAnyGroup() [5/6]

ChimeraTK::ReadAnyGroup::ReadAnyGroup ( const ReadAnyGroup )
delete

◆ ReadAnyGroup() [6/6]

ChimeraTK::ReadAnyGroup::ReadAnyGroup ( ReadAnyGroup &&  other)
inlinenoexcept

Definition at line 162 of file ReadAnyGroup.h.

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 503 of file ReadAnyGroup.h.

◆ 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 472 of file ReadAnyGroup.h.

◆ 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 510 of file ReadAnyGroup.h.

◆ 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 283 of file ReadAnyGroup.h.

◆ operator=()

ReadAnyGroup & ChimeraTK::ReadAnyGroup::operator= ( ReadAnyGroup &&  other)
inlinenoexcept

Definition at line 457 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 652 of file ReadAnyGroup.h.

◆ 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 530 of file ReadAnyGroup.h.

◆ 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 543 of file ReadAnyGroup.h.

◆ readUntil() [1/2]

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

See the other signature of readUntil().

Definition at line 670 of file ReadAnyGroup.h.

◆ 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 661 of file ReadAnyGroup.h.

◆ readUntilAll() [1/2]

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

See the other signature of readUntilAll().

Definition at line 695 of file ReadAnyGroup.h.

◆ 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 676 of file ReadAnyGroup.h.

◆ 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 582 of file ReadAnyGroup.h.

◆ 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 595 of file ReadAnyGroup.h.

Friends And Related Symbol Documentation

◆ ChimeraTK::DataConsistencyGroupDetail::HistorizedMatcher

Definition at line 27 of file ReadAnyGroup.h.


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