ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
DataConsistencyGroup.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
6
7namespace ChimeraTK {
8
9 /********************************************************************************************************************/
10
11 namespace DataConsistencyGroupDetail {
12 class MatcherBase;
13 }
14
28 public:
30 enum class MatchingMode {
31 none,
32 exact,
35 };
36 constexpr static unsigned defaultHistLen = 2;
37
44
46 [[deprecated("use list constructor with MatchingMode instead")]]
47 DataConsistencyGroup(std::initializer_list<TransferElementAbstractor> list);
48 [[deprecated("use list constructor with MatchingMode instead")]]
49 DataConsistencyGroup(std::initializer_list<boost::shared_ptr<TransferElement>> list);
50 DataConsistencyGroup(std::initializer_list<std::reference_wrapper<TransferElementAbstractor>> list,
51 MatchingMode mode, unsigned histLen = defaultHistLen);
52
53 template<typename ITERATOR>
55 ITERATOR first, ITERATOR last, MatchingMode mode = MatchingMode::exact, unsigned int histLen = defaultHistLen);
56
59 [[deprecated("use add function with histLen instead")]]
60 void add(const TransferElementAbstractor& element);
61 [[deprecated("use add function with histLen instead")]]
62 void add(boost::shared_ptr<TransferElement> element);
67 void add(TransferElementAbstractor& acc, unsigned histLen = defaultHistLen);
68
75 bool update(const TransferElementID& transferElementID);
76
80 [[deprecated("set MatchingMode in constructor instead")]]
81 void setMatchingMode(MatchingMode newMode);
82
84 [[nodiscard]] MatchingMode getMatchingMode() const { return _mode; };
85
87 [[nodiscard]] const std::map<TransferElementID, TransferElementAbstractor>& getElements() const;
90
92 [[nodiscard]] bool isConsistent() const;
93
94 private:
95 void initMatcher();
96 static void checkAccess(const TransferElementAbstractor& element);
97
100
101 std::unique_ptr<DataConsistencyGroupDetail::MatcherBase> _impl;
102 };
103
104 /********************************************************************************************************************/
105
106 template<typename ITERATOR>
107 DataConsistencyGroup::DataConsistencyGroup(ITERATOR first, ITERATOR last, MatchingMode mode, unsigned int histLen)
108 : _mode(mode) {
109 initMatcher();
110 for(auto it = first; it != last; ++it) {
111 add(*it, histLen);
112 }
113 }
114
115 /********************************************************************************************************************/
116
117} // namespace ChimeraTK
Base class for matcher implementations; will not be instantiated directly.
Group several registers (= TransferElement) which ensures data consistency across multiple variables ...
DataConsistencyGroup(DataConsistencyGroup &&other) noexcept
const DataConsistencyGroupDetail::MatcherBase & getMatcher()
For diagnostics.
void setMatchingMode(MatchingMode newMode)
Change the matching mode.
void add(const TransferElementAbstractor &element)
Add register to group.
MatchingMode getMatchingMode() const
Return the current matching mode.
DataConsistencyGroup(const DataConsistencyGroup &other)=delete
DataConsistencyGroup & operator=(DataConsistencyGroup &&other) noexcept
MatchingMode
Enum describing the matching mode of a DataConsistencyGroup.
@ 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.
const std::map< TransferElementID, TransferElementAbstractor > & getElements() const
For inspection of contents.
DataConsistencyGroup(MatchingMode mode=MatchingMode::exact)
Construct empty group.
bool isConsistent() const
returns true if consistent state is reached
bool update(const TransferElementID &transferElementID)
This function must be called after an update was received from the ReadAnyGroup.
static constexpr unsigned defaultHistLen
Base class for register accessors abstractors independent of the UserType.
Simple class holding a unique ID for a TransferElement.