ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
TwoDRegisterAccessor.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 <boost/smart_ptr.hpp>
8
9namespace ChimeraTK {
10
11 /********************************************************************************************************************/
12
16 template<user_type UserType>
18 public:
20 // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions)
21 TwoDRegisterAccessor(boost::shared_ptr<NDRegisterAccessor<UserType>> _accessor);
22
30
32 std::vector<UserType>& operator[](size_t channel) { return get()->accessChannel(channel); }
33
35 const std::vector<UserType>& operator[](size_t channel) const { return get()->accessChannel(channel); }
36
38 TwoDRegisterAccessor<UserType>& operator=(const std::vector<std::vector<UserType>>& other);
39
41 [[nodiscard]] size_t getNChannels() const { return get()->getNumberOfChannels(); }
42
44 [[nodiscard]] size_t getNElementsPerChannel() const { return get()->getNumberOfSamples(); }
45
50 template<typename COOKED_TYPE>
51 COOKED_TYPE getAsCooked(unsigned int channel, unsigned int sample) const;
52
57 template<typename COOKED_TYPE>
58 void setAsCooked(unsigned int channel, unsigned int sample, COOKED_TYPE value);
59
60 friend class TransferGroup;
61
63 };
64
65 /********************************************************************************************************************/
66 /********************************************************************************************************************/
67
68 template<user_type UserType>
70 : NDRegisterAccessorAbstractor<UserType>(_accessor) {
71 static_assert(!std::is_same<UserType, Void>::value,
72 "You cannot create TwoDRegisterAccessor<ChimeraTK::Void>! Use VoidRegisterAccessor instead.");
73 }
74
75 /********************************************************************************************************************/
76
77 template<user_type UserType>
79 static_assert(!std::is_same<UserType, Void>::value,
80 "You cannot create TwoDRegisterAccessor<ChimeraTK::Void>! Use VoidRegisterAccessor instead.");
81 }
82
83 /********************************************************************************************************************/
84
85 template<user_type UserType>
87 const std::vector<std::vector<UserType>>& other) {
88 get()->accessChannels() = other;
89 return *this;
90 }
91
92 /********************************************************************************************************************/
93
94 template<user_type UserType>
95 template<typename COOKED_TYPE>
96 COOKED_TYPE TwoDRegisterAccessor<UserType>::getAsCooked(unsigned int channel, unsigned int sample) const {
97 return get()->template getAsCooked<COOKED_TYPE>(channel, sample);
98 }
99
100 /********************************************************************************************************************/
101
102 template<user_type UserType>
103 template<typename COOKED_TYPE>
104 void TwoDRegisterAccessor<UserType>::setAsCooked(unsigned int channel, unsigned int sample, COOKED_TYPE value) {
105 return get()->template setAsCooked<COOKED_TYPE>(channel, sample, value);
106 }
107
108 /********************************************************************************************************************/
109
110 // Do not declare the template for all user types as extern here.
111 // This could avoid optimisation of the inline code.
112
113} // namespace ChimeraTK
Base class for the register accessor abstractors (ScalarRegisterAccessor, OneDRegisterAccessor and Tw...
N-dimensional register accessor.
Group multiple data accessors to efficiently trigger data transfers on the whole group.
Accessor class to read and write 2D registers.
COOKED_TYPE getAsCooked(unsigned int channel, unsigned int sample) const
Get the cooked values in case the accessor is a raw accessor (which does not do data conversion).
void setAsCooked(unsigned int channel, unsigned int sample, COOKED_TYPE value)
Set the cooked values in case the accessor is a raw accessor (which does not do data conversion).
size_t getNElementsPerChannel() const
Return number of elements/samples per channel.
TwoDRegisterAccessor< UserType > & operator=(const std::vector< std::vector< UserType > > &other)
Assignment operator to assign the entire 2D array.
size_t getNChannels() const
Return the number of channels (formerly called sequences)
std::vector< UserType > & operator[](size_t channel)
Operator to access individual sequences/channels.
const std::vector< UserType > & operator[](size_t channel) const
Const operator to access individual sequences/channels.
TwoDRegisterAccessor()
Placeholder constructer, to allow late initialisation of the accessor, e.g.