ChimeraTK-DeviceAccess 03.20.00
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChimeraTK::DataConsistencyGroup Class Reference

Group several registers (= TransferElement) which ensures data consistency across multiple variables through an algorithm which matches the VersionNumber. More...

#include <DataConsistencyGroup.h>

Public Types

enum class  MatchingMode { none , exact , historized }
 Enum describing the matching mode of a DataConsistencyGroup. More...
 

Public Member Functions

 DataConsistencyGroup (MatchingMode mode=MatchingMode::exact)
 Construct empty group.
 
 ~DataConsistencyGroup ()
 
 DataConsistencyGroup (const DataConsistencyGroup &other)=delete
 
 DataConsistencyGroup (DataConsistencyGroup &&other) noexcept
 
DataConsistencyGroupoperator= (DataConsistencyGroup &&other) noexcept
 
 DataConsistencyGroup (std::initializer_list< TransferElementAbstractor > list)
 Construct this group with elements from the list using the add() function.
 
 DataConsistencyGroup (std::initializer_list< boost::shared_ptr< TransferElement > > list)
 
 DataConsistencyGroup (std::initializer_list< std::reference_wrapper< TransferElementAbstractor > > list, MatchingMode mode, unsigned histLen=defaultHistLen)
 
template<typename ITERATOR >
 DataConsistencyGroup (ITERATOR first, ITERATOR last, MatchingMode mode=MatchingMode::exact, unsigned int histLen=defaultHistLen)
 
void add (const TransferElementAbstractor &element)
 Add register to group.
 
void add (boost::shared_ptr< TransferElement > element)
 
void add (TransferElementAbstractor &acc, unsigned histLen=defaultHistLen)
 Add register to group.
 
bool update (const TransferElementID &transferElementID)
 This function must be called after an update was received from the ReadAnyGroup.
 
void setMatchingMode (MatchingMode newMode)
 Change the matching mode.
 
MatchingMode getMatchingMode () const
 Return the current matching mode.
 
const std::map< TransferElementID, TransferElementAbstractor > & getElements () const
 For inspection of contents.
 
const DataConsistencyGroupDetail::MatcherBasegetMatcher ()
 For diagnostics.
 
bool isConsistent () const
 returns true if consistent state is reached
 

Static Public Attributes

static constexpr unsigned defaultHistLen = 2
 

Detailed Description

Group several registers (= TransferElement) which ensures data consistency across multiple variables through an algorithm which matches the VersionNumber.

This group does not read on its own. It should work together with a ReadAnyGroup. This is a proxy class, which delegates to two different implementations. MatchingMode=exact is handled by SimpleMatcher (the legacy DataConsistencyGroup implementation). For this, you should wait for changed variable and transfer it to this group by calling DataConsistencyGroup::update. If a consistent state is reached, this function returns true. MatchingMode=historized is handled by HistorizedMatcher. In this case, the provided accessors are decorated with DataConsistencyDecorators, with the effect that the readAny() returns only on consistent inputs. In this mode, it is unnecessary but still allowed to call DataConsistencyGroup::update and it simply returns true.

Definition at line 27 of file DataConsistencyGroup.h.

Member Enumeration Documentation

◆ MatchingMode

Enum describing the matching mode of a DataConsistencyGroup.

Enumerator
none 

No matching, effectively disable the DataConsitencyGroup. update() will always return true.

exact 

Require an exact match of the VersionNumber of all current values of the group's members.

Require an exact match of the VersionNumber of all current or historized values of the group's members

historized 

Definition at line 30 of file DataConsistencyGroup.h.

Constructor & Destructor Documentation

◆ DataConsistencyGroup() [1/7]

ChimeraTK::DataConsistencyGroup::DataConsistencyGroup ( MatchingMode  mode = MatchingMode::exact)
explicit

Construct empty group.

Elements can later be added using the add() function.

Definition at line 24 of file DataConsistencyGroup.cc.

◆ ~DataConsistencyGroup()

ChimeraTK::DataConsistencyGroup::~DataConsistencyGroup ( )
default

◆ DataConsistencyGroup() [2/7]

ChimeraTK::DataConsistencyGroup::DataConsistencyGroup ( const DataConsistencyGroup other)
delete

◆ DataConsistencyGroup() [3/7]

ChimeraTK::DataConsistencyGroup::DataConsistencyGroup ( DataConsistencyGroup &&  other)
defaultnoexcept

◆ DataConsistencyGroup() [4/7]

ChimeraTK::DataConsistencyGroup::DataConsistencyGroup ( std::initializer_list< TransferElementAbstractor list)

Construct this group with elements from the list using the add() function.

Definition at line 38 of file DataConsistencyGroup.cc.

◆ DataConsistencyGroup() [5/7]

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

Definition at line 51 of file DataConsistencyGroup.cc.

◆ DataConsistencyGroup() [6/7]

ChimeraTK::DataConsistencyGroup::DataConsistencyGroup ( std::initializer_list< std::reference_wrapper< TransferElementAbstractor > >  list,
MatchingMode  mode,
unsigned  histLen = defaultHistLen 
)

Definition at line 64 of file DataConsistencyGroup.cc.

◆ DataConsistencyGroup() [7/7]

template<typename ITERATOR >
ChimeraTK::DataConsistencyGroup::DataConsistencyGroup ( ITERATOR  first,
ITERATOR  last,
MatchingMode  mode = MatchingMode::exact,
unsigned int  histLen = defaultHistLen 
)

Definition at line 107 of file DataConsistencyGroup.h.

Member Function Documentation

◆ add() [1/3]

void ChimeraTK::DataConsistencyGroup::add ( boost::shared_ptr< TransferElement element)

Definition at line 88 of file DataConsistencyGroup.cc.

◆ add() [2/3]

void ChimeraTK::DataConsistencyGroup::add ( const TransferElementAbstractor element)

Add register to group.

The same TransferElement can be part of multiple DataConsistencyGroups. The register must be must be readable, and it must have AccessMode::wait_for_new_data.

Definition at line 77 of file DataConsistencyGroup.cc.

◆ add() [3/3]

void ChimeraTK::DataConsistencyGroup::add ( TransferElementAbstractor acc,
unsigned  histLen = defaultHistLen 
)

Add register to group.

The same TransferElement can be part of multiple DataConsistencyGroups. The register must be must be readable, and it must have AccessMode::wait_for_new_data. This function may modify the register accessor, placing a DataConsistencyDecorator around it.

Definition at line 110 of file DataConsistencyGroup.cc.

◆ getElements()

const std::map< TransferElementID, TransferElementAbstractor > & ChimeraTK::DataConsistencyGroup::getElements ( ) const

For inspection of contents.

Definition at line 156 of file DataConsistencyGroup.cc.

◆ getMatcher()

const DataConsistencyGroupDetail::MatcherBase & ChimeraTK::DataConsistencyGroup::getMatcher ( )

For diagnostics.

Definition at line 162 of file DataConsistencyGroup.cc.

◆ getMatchingMode()

MatchingMode ChimeraTK::DataConsistencyGroup::getMatchingMode ( ) const
inline

Return the current matching mode.

Definition at line 84 of file DataConsistencyGroup.h.

◆ isConsistent()

bool ChimeraTK::DataConsistencyGroup::isConsistent ( ) const

returns true if consistent state is reached

Definition at line 168 of file DataConsistencyGroup.cc.

◆ operator=()

DataConsistencyGroup & ChimeraTK::DataConsistencyGroup::operator= ( DataConsistencyGroup &&  other)
defaultnoexcept

◆ setMatchingMode()

void ChimeraTK::DataConsistencyGroup::setMatchingMode ( MatchingMode  newMode)

Change the matching mode.

The default mode is MatchingMode::exact, if not set differently in constructor. This method is deprecated since it's not possible to set MatchingMode::historized like this.

Definition at line 144 of file DataConsistencyGroup.cc.

◆ update()

bool ChimeraTK::DataConsistencyGroup::update ( const TransferElementID transferElementID)

This function must be called after an update was received from the ReadAnyGroup.

It returns true, if a consistent state is reached. It returns false if an TransferElementID was updated, that was not added to this group. For MatchingMode::historized, readAny will only let through consistent updates, so then update always returns true.

Definition at line 122 of file DataConsistencyGroup.cc.

Member Data Documentation

◆ defaultHistLen

constexpr unsigned ChimeraTK::DataConsistencyGroup::defaultHistLen = 2
staticconstexpr

Definition at line 36 of file DataConsistencyGroup.h.


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