ChimeraTK-DeviceAccess  03.18.00
TransferGroup.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 
7 #include <set>
8 
9 namespace ChimeraTK {
10 
26  class TransferGroup {
27  public:
33  void addAccessor(TransferElementAbstractor& accessor);
34 
36  void addAccessor(const boost::shared_ptr<TransferElement>& accessor);
37 
39  void read();
40 
42  void write(VersionNumber versionNumber = {});
43 
48  [[nodiscard]] bool isReadOnly();
49 
53  [[nodiscard]] bool isReadable();
54 
58  [[nodiscard]] bool isWriteable();
59 
64  void dump();
65 
66  protected:
71  std::map<boost::shared_ptr<TransferElement>, bool /*hasSeenException*/> _lowLevelElementsAndExceptionFlags;
72 
77  std::set<boost::shared_ptr<TransferElement>> _copyDecorators;
78 
80  std::set<boost::shared_ptr<TransferElement>> _highLevelElements;
81 
86  std::set<boost::shared_ptr<DeviceBackend>> _exceptionBackends;
87 
89  bool _isReadable{false};
90 
92  bool _isWriteable{false};
93 
96 
99 
100  // Helper function to avoid code duplication. Needs to be run for two lists.
101  void runPostReads(const std::set<boost::shared_ptr<TransferElement>>& elements,
102  const std::exception_ptr& firstDetectedRuntimeError) noexcept;
103 
104  // Counter how many runtime errors have been thrown.
106 
107  private:
108  void addAccessorImpl(TransferElementAbstractor& accessor, bool isTemporaryAbstractor);
109  };
110 
111 } /* namespace ChimeraTK */
ChimeraTK::TransferGroup::_copyDecorators
std::set< boost::shared_ptr< TransferElement > > _copyDecorators
List of all CopyRegisterDecorators in the group.
Definition: TransferGroup.h:77
ChimeraTK::TransferGroup::write
void write(VersionNumber versionNumber={})
Trigger write transfer for all accessors in the group.
Definition: TransferGroup.cc:123
ChimeraTK::TransferGroup::addAccessor
void addAccessor(TransferElementAbstractor &accessor)
Add a register accessor to the group.
Definition: TransferGroup.cc:305
ChimeraTK::TransferGroup::isReadable
bool isReadable()
Check if transfer group is readable.
Definition: TransferGroup.cc:192
ChimeraTK::TransferGroup::isReadOnly
bool isReadOnly()
Check if transfer group is read-only.
Definition: TransferGroup.cc:186
ChimeraTK::TransferGroup
Group multiple data accessors to efficiently trigger data transfers on the whole group.
Definition: TransferGroup.h:26
ChimeraTK::TransferGroup::isWriteable
bool isWriteable()
Check if transfer group is writeable.
Definition: TransferGroup.cc:201
ChimeraTK::TransferGroup::read
void read()
Trigger read transfer for all accessors in the group.
Definition: TransferGroup.cc:44
ChimeraTK::TransferElementAbstractor
Base class for register accessors abstractors independent of the UserType.
Definition: TransferElementAbstractor.h:28
ChimeraTK::TransferGroup::_lowLevelElementsAndExceptionFlags
std::map< boost::shared_ptr< TransferElement >, bool > _lowLevelElementsAndExceptionFlags
List of low-level TransferElements in this group, which are directly responsible for the hardware acc...
Definition: TransferGroup.h:71
ChimeraTK::TransferGroup::_cachedReadableWriteableIsValid
bool _cachedReadableWriteableIsValid
Flag whether to update the cached information.
Definition: TransferGroup.h:95
ChimeraTK::TransferGroup::_exceptionBackends
std::set< boost::shared_ptr< DeviceBackend > > _exceptionBackends
List of all exception backends.
Definition: TransferGroup.h:86
TransferElementAbstractor.h
ChimeraTK::TransferGroup::updateIsReadableWriteable
void updateIsReadableWriteable()
Helper function to update the cached state variables.
Definition: TransferGroup.cc:311
ChimeraTK::TransferGroup::_isReadable
bool _isReadable
Cached value whether all elements are readable.
Definition: TransferGroup.h:89
ChimeraTK::TransferGroup::runPostReads
void runPostReads(const std::set< boost::shared_ptr< TransferElement >> &elements, const std::exception_ptr &firstDetectedRuntimeError) noexcept
Definition: TransferGroup.cc:17
ChimeraTK::TransferGroup::_nRuntimeErrors
size_t _nRuntimeErrors
Definition: TransferGroup.h:105
ChimeraTK::VersionNumber
Class for generating and holding version numbers without exposing a numeric representation.
Definition: VersionNumber.h:23
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::TransferGroup::_isWriteable
bool _isWriteable
Cached value whether all elements are writeable.
Definition: TransferGroup.h:92
ChimeraTK::TransferGroup::dump
void dump()
Print information about the accessors in this group to screen, which might help to understand which t...
Definition: TransferGroup.cc:323
ChimeraTK::TransferGroup::_highLevelElements
std::set< boost::shared_ptr< TransferElement > > _highLevelElements
List of high-level TransferElements in this group which are directly used by the user.
Definition: TransferGroup.h:80