ChimeraTK-DeviceAccess  03.18.00
CopyRegisterDecorator.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 #include "TransferElement.h"
7 
8 namespace ChimeraTK {
9 
14 
24  template<typename T>
26  explicit CopyRegisterDecorator(const boost::shared_ptr<ChimeraTK::NDRegisterAccessor<T>>& target)
28  if(!target->isReadable()) {
29  throw ChimeraTK::logic_error("ChimeraTK::CopyRegisterDecorator: Target accessor is not readable.");
30  }
31  }
32 
34  throw ChimeraTK::logic_error("ChimeraTK::CopyRegisterDecorator: Accessor is not writeable.");
35  }
36 
37  void doPostRead(TransferType type, bool hasNewData) override {
38  _target->postRead(type, hasNewData);
39  if(hasNewData) {
40  for(size_t i = 0; i < _target->getNumberOfChannels(); ++i) buffer_2D[i] = _target->accessChannel(i);
41  }
42  }
43 
44  [[nodiscard]] bool isReadOnly() const override { return true; }
45 
46  [[nodiscard]] bool isWriteable() const override { return false; }
47 
50  };
51 
52 } // namespace ChimeraTK
TransferElement.h
ChimeraTK::NDRegisterAccessor< T >::buffer_2D
std::vector< std::vector< T > > buffer_2D
Buffer of converted data elements.
Definition: NDRegisterAccessor.h:123
ChimeraTK::CopyRegisterDecorator::CopyRegisterDecorator
CopyRegisterDecorator(const boost::shared_ptr< ChimeraTK::NDRegisterAccessor< T >> &target)
Definition: CopyRegisterDecorator.h:26
NDRegisterAccessorDecorator.h
ChimeraTK::CopyRegisterDecorator::doPostRead
void doPostRead(TransferType type, bool hasNewData) override
Definition: CopyRegisterDecorator.h:37
ChimeraTK::CopyRegisterDecorator::isWriteable
bool isWriteable() const override
Definition: CopyRegisterDecorator.h:46
ChimeraTK::CopyRegisterDecoratorTrait
Runtime type trait to identify CopyRegisterDecorators independent of their type.
Definition: CopyRegisterDecorator.h:13
ChimeraTK::CopyRegisterDecorator
Decorator for NDRegisterAccessors which makes a copy of the data from the target accessor.
Definition: CopyRegisterDecorator.h:25
ChimeraTK::TransferType
TransferType
Used to indicate the applicable operation on a Transferelement.
Definition: TransferElement.h:51
ChimeraTK::NDRegisterAccessorDecorator
Base class for decorators of the NDRegisterAccessor.
Definition: NDRegisterAccessorDecorator.h:120
ChimeraTK::CopyRegisterDecorator::doPreWrite
void doPreWrite(TransferType, VersionNumber) override
Definition: CopyRegisterDecorator.h:33
ChimeraTK::VersionNumber
Class for generating and holding version numbers without exposing a numeric representation.
Definition: VersionNumber.h:23
ChimeraTK::CopyRegisterDecorator::isReadOnly
bool isReadOnly() const override
Definition: CopyRegisterDecorator.h:44
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::NDRegisterAccessor< T >
ChimeraTK::logic_error
Exception thrown when a logic error has occured.
Definition: Exception.h:51