19 template<user_type UserType>
46 UserType&
operator[](
unsigned int element) {
return get()->accessData(0, element); }
54 using iterator =
typename std::vector<UserType>::iterator;
74 void swap(std::vector<UserType>& x)
noexcept;
87 operator const std::vector<UserType>&() {
return get()->accessChannel(0); }
96 UserType*
data() {
return get()->accessChannel(0).data(); }
102 template<
typename COOKED_TYPE>
109 template<
typename COOKED_TYPE>
128 template<user_type UserType>
131 static_assert(!std::is_same<UserType, Void>::value,
132 "You cannot create OneDRegisterAccessor<ChimeraTK::Void>! Use VoidRegisterAccessor instead.");
134 if(
get()->getNumberOfChannels() != 1) {
136 "dimension to access the register " + impl->getName());
142 template<user_type UserType>
144 static_assert(!std::is_same<UserType, Void>::value,
145 "You cannot create OneDRegisterAccessor<ChimeraTK::Void>! Use VoidRegisterAccessor instead.");
153 template<user_type UserType>
155 if(x.size() != get()->accessChannel(0).size()) {
158 std::cerr <<
"Swapping with a buffer of a different size is not allowed." << std::endl;
161 get()->accessChannel(0).swap(x);
169 template<user_type UserType>
171 if(x.size() != get()->accessChannel(0).size()) {
174 get()->accessChannel(0) = x;
184 template<user_type UserType>
185 template<
typename COOKED_TYPE>
187 return get()->template getAsCooked<COOKED_TYPE>(0, sample);
196 template<user_type UserType>
197 template<
typename COOKED_TYPE>
199 return get()->template setAsCooked<COOKED_TYPE>(0, sample, value);
209 template<user_type UserType>
212 if(!std::equal(newValue.begin(), newValue.end(), get()->accessChannel(0).begin()) ||
213 this->getVersionNumber() ==
VersionNumber(
nullptr) || this->dataValidity() != validity) {
215 if(versionNumber ==
VersionNumber{
nullptr}) versionNumber = {};
216 this->setDataValidity(validity);
217 this->
write(versionNumber);
Base class for the register accessor abstractors (ScalarRegisterAccessor, OneDRegisterAccessor and Tw...
NDRegisterAccessor< UserType > * get()
N-dimensional register accessor.
Accessor class to read and write registers transparently by using the accessor object like a vector o...
const_iterator end() const
OneDRegisterAccessor()
Placeholder constructer, to allow late initialisation of the accessor, e.g.
void writeIfDifferent(const std::vector< UserType > &newValue, VersionNumber versionNumber=VersionNumber{nullptr}, DataValidity validity=DataValidity::ok)
Convenience function to set and write new value if it differes from the current value.
typename std::vector< UserType >::const_reverse_iterator const_reverse_iterator
OneDRegisterAccessor(boost::shared_ptr< NDRegisterAccessor< UserType > > impl)
Create accessor from pointer to implementation.
UserType * data()
Return a direct pointer to the memory buffer storng the elements.
UserType & operator[](unsigned int element)
Get or set buffer content by [] operator.
const_iterator cbegin() const
const_reverse_iterator rbegin() const
const_reverse_iterator crbegin() const
typename std::vector< UserType >::iterator iterator
const_iterator begin() const
void swap(std::vector< UserType > &x) noexcept
Swap content of (cooked) buffer with std::vector.
unsigned int getNElements()
Return number of elements/samples in the register.
COOKED_TYPE getAsCooked(unsigned int sample)
Get the cooked values in case the accessor is a raw accessor (which does not do data conversion).
OneDRegisterAccessor< UserType > & operator=(const std::vector< UserType > &x)
Copy content of (cooked) buffer from std::vector.
const_iterator cend() const
typename std::vector< UserType >::reverse_iterator reverse_iterator
const_reverse_iterator crend() const
typename std::vector< UserType >::const_iterator const_iterator
reverse_iterator rbegin()
void setAsCooked(unsigned int sample, COOKED_TYPE value)
Set the cooked values in case the accessor is a raw accessor (which does not do data conversion).
const_reverse_iterator rend() const
Group multiple data accessors to efficiently trigger data transfers on the whole group.
Class for generating and holding version numbers without exposing a numeric representation.
Exception thrown when a logic error has occured.
DataValidity
The current state of the data.