ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
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
8namespace 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
33 void doPreRead(TransferType) override {
34 // Do nothing. This should only ever be called from the TransferGroup which has already handled
35 // the preRead differently
36 }
37
39 throw ChimeraTK::logic_error("ChimeraTK::CopyRegisterDecorator: Accessor is not writeable.");
40 }
41
42 void doPostRead(TransferType type, bool hasNewData) override {
43 _target->postRead(type, hasNewData);
44 if(hasNewData) {
45 for(size_t i = 0; i < _target->getNumberOfChannels(); ++i) buffer_2D[i] = _target->accessChannel(i);
46 }
47 }
48
50 std::cerr << "CopyRegisterDecorator::doReadTransferSynchronously: Must not be called" << std::endl;
51 assert(false);
52 }
53
54 [[nodiscard]] bool isReadOnly() const override { return true; }
55
56 [[nodiscard]] bool isWriteable() const override { return false; }
57
60 };
61
62} // namespace ChimeraTK
Base class for decorators of the NDRegisterAccessor.
N-dimensional register accessor.
std::vector< std::vector< UserType > > buffer_2D
Buffer of converted data elements.
Class for generating and holding version numbers without exposing a numeric representation.
Exception thrown when a logic error has occured.
Definition Exception.h:51
TransferType
Used to indicate the applicable operation on a Transferelement.
Decorator for NDRegisterAccessors which makes a copy of the data from the target accessor.
CopyRegisterDecorator(const boost::shared_ptr< ChimeraTK::NDRegisterAccessor< T > > &target)
void doPostRead(TransferType type, bool hasNewData) override
Backend specific implementation of postRead().
void doPreRead(TransferType) override
Backend specific implementation of preRead().
bool isReadOnly() const override
Check if transfer element is read only, i.e.
void doReadTransferSynchronously()
Implementation version of readTransfer() for synchronous reads.
void doPreWrite(TransferType, VersionNumber) override
Backend specific implementation of preWrite().
bool isWriteable() const override
Check if transfer element is writeable.
Runtime type trait to identify CopyRegisterDecorators independent of their type.