11#include <boost/shared_ptr.hpp>
25 template<
typename DATA_TYPE>
26 struct pitched_iterator {
28 using iterator_category = std::random_access_iterator_tag;
29 using value_type = DATA_TYPE;
30 using difference_type = std::ptrdiff_t;
31 using pointer = DATA_TYPE*;
32 using reference = DATA_TYPE&;
35 pitched_iterator(
void* begin,
size_t pitch) : _ptr(
reinterpret_cast<std::byte*
>(begin)), _pitch(pitch) {}
37 template<
typename OTHER_DATA_TYPE>
38 explicit pitched_iterator(pitched_iterator<OTHER_DATA_TYPE>& other) : _ptr(other._ptr), _pitch(other._pitch) {}
40 pitched_iterator& operator++() {
44 pitched_iterator operator++(
int) {
45 pitched_iterator retval = *
this;
49 pitched_iterator
operator+(
size_t n) {
return pitched_iterator(_ptr + n * _pitch, _pitch); }
50 bool operator==(pitched_iterator other)
const {
return _ptr == other._ptr; }
51 bool operator!=(pitched_iterator other)
const {
return !(*
this == other); }
52 size_t operator-(pitched_iterator other)
const {
return _ptr - other._ptr; }
54 DATA_TYPE&
operator*()
const {
return *
reinterpret_cast<DATA_TYPE*
>(_ptr); }
60 template<
typename OTHER_DATA_TYPE>
61 friend struct pitched_iterator;
70 template<
class UserType>
74 size_t elementsOffset,
const boost::shared_ptr<DeviceBackend>& _backend);
96 [[nodiscard]]
bool mayReplaceOther(
const boost::shared_ptr<TransferElement const>& other)
const override {
97 auto rhsCasted = boost::dynamic_pointer_cast<const NumericAddressedBackendMuxedRegisterAccessor<UserType>>(other);
98 if(rhsCasted.get() ==
this) {
101 if(!rhsCasted)
return false;
102 if(
_ioDevice != rhsCasted->_ioDevice)
return false;
128 return {boost::enable_shared_from_this<TransferElement>::shared_from_this()};
#define DECLARE_TEMPLATE_FOR_CHIMERATK_USER_TYPES(TemplateClass)
N-dimensional register accessor.
std::vector< std::vector< UserType > > buffer_2D
Buffer of converted data elements.
Implementation of the NDRegisterAccessor for NumericAddressedBackends for multiplexd 2D registers.
std::vector< detail::pitched_iterator< int32_t > > _startIterators
void doPreWriteImpl(RawConverter::Converter< UserType2, RawType, sc, fc, isSigned > converter, size_t channelIndex)
bool mayReplaceOther(const boost::shared_ptr< TransferElement const > &other) const override
Check whether the TransferElement can be used in places where the TransferElement "other" is currentl...
void doPostReadImpl(RawConverter::Converter< UserType2, RawType, sc, fc, isSigned > converter, size_t channelIndex)
bool isWriteable() const override
Check if transfer element is writeable.
void doReadTransferSynchronously() override
Implementation version of readTransfer() for synchronous reads.
std::vector< std::unique_ptr< RawConverter::ConverterLoopHelper > > _converterLoopHelpers
bool isReadOnly() const override
Check if transfer element is read only, i.e.
void doPostRead(TransferType type, bool hasNewData) override
Backend specific implementation of postRead().
bool doWriteTransfer(ChimeraTK::VersionNumber versionNumber) override
Implementation version of writeTransfer().
void doPreWrite(TransferType type, VersionNumber versionNumber) override
Backend specific implementation of preWrite().
void doPreRead(TransferType) override
Backend specific implementation of preRead().
std::vector< detail::pitched_iterator< int32_t > > _endIterators
std::vector< boost::shared_ptr< TransferElement > > getHardwareAccessingElements() override
Obtain the underlying TransferElements with actual hardware access.
std::list< boost::shared_ptr< TransferElement > > getInternalElements() override
Obtain the full list of TransferElements internally used by this TransferElement.
std::vector< int32_t > _ioBuffer
bool isReadable() const override
Check if transfer element is readable.
NumericAddressedRegisterInfo _registerInfo
boost::shared_ptr< NumericAddressedBackend > _ioDevice
The device from (/to) which to perform the DMA transfer.
void replaceTransferElement(boost::shared_ptr< TransferElement >) override
Search for all underlying TransferElements which are considered identical (see sameRegister()) with t...
bool isReadable() const override
Return whether the register is readable.
bool isWriteable() const override
Return whether the register is writeable.
Converter class for conversions from raw to cooked values.
Class to store a register path name.
boost::shared_ptr< DeviceBackend > _exceptionBackend
The backend to which the runtime_errors are reported via DeviceBackend::setException().
Class for generating and holding version numbers without exposing a numeric representation.
Exception thrown when a logic error has occured.
std::string operator+(const std::string &leftHandSide, const RegisterPath &rightHandSide)
non-member + operator for RegisterPath: concatenate with normal strings.
constexpr auto MULTIPLEXED_SEQUENCE_PREFIX
constexpr auto SEQUENCE_PREFIX
constexpr auto MEM_MULTIPLEXED_PREFIX
TransferType
Used to indicate the applicable operation on a Transferelement.
RegisterPath operator*(const RegisterPath &leftHandSide, int rightHandSide)