8#include <ChimeraTK/OneDRegisterAccessor.h>
9#include <ChimeraTK/SystemTags.h>
11#include <boost/smart_ptr/shared_ptr.hpp>
12#include <boost/thread.hpp>
23 template<
typename UserType>
28 void replace(
const ChimeraTK::NDRegisterAccessorAbstractor<UserType>& newAccessor) =
delete;
31 using ChimeraTK::OneDRegisterAccessor<UserType>::operator=;
39 bool write(ChimeraTK::VersionNumber versionNumber) =
delete;
42 const std::vector<UserType>& newValue, VersionNumber versionNumber, DataValidity validity) =
delete;
43 void setAndWrite(
const std::vector<UserType>& newValue, VersionNumber versionNumber) =
delete;
61 size_t nElements,
UpdateMode mode,
const std::string& description,
62 const std::unordered_set<std::string>& tags = {});
71 template<
typename UserType>
75 const std::string& description,
const std::unordered_set<std::string>& tags = {});
83 template<
typename UserType>
87 const std::string& description,
const std::unordered_set<std::string>& tags = {});
89 void read() { this->readLatest(); }
96 template<
typename UserType>
100 const std::string& description,
const std::unordered_set<std::string>& tags = {});
109 template<
typename UserType>
113 const std::string& description,
const std::unordered_set<std::string>& tags = {});
122 template<
typename UserType>
126 const std::string& description,
const std::unordered_set<std::string>& tags = {});
134 template<
typename UserType>
137 [[deprecated]]
ArrayOutputRB(
Module* owner,
const std::string& name, std::string unit,
size_t nElements,
138 const std::string& description,
const std::unordered_set<std::string>& tags = {});
145 template<
typename UserType>
149 const std::string& description,
const std::unordered_set<std::string>& tags = {});
159 template<
typename UserType>
166 template<
typename UserType>
176 template<
typename UserType>
178 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
179 bool dataLoss = ChimeraTK::OneDRegisterAccessor<UserType>::write(versionNumber);
188 template<
typename UserType>
190 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
191 bool dataLoss = ChimeraTK::OneDRegisterAccessor<UserType>::writeDestructively(versionNumber);
200 template<
typename UserType>
202 if(!std::equal(newValue.begin(), newValue.end(), this->get()->accessChannel(0).begin()) ||
203 this->template checkMetadataWriteDifference<UserType>()) {
204 setAndWrite(newValue);
210 template<
typename UserType>
218 template<
typename UserType>
220 std::string unit,
size_t nElements,
UpdateMode mode,
const std::string& description,
221 const std::unordered_set<std::string>& tags)
223 owner, name, direction, unit, nElements, mode, description, &typeid(UserType), tags) {
230 template<
typename UserType>
232 const std::string& description,
const std::unordered_set<std::string>& tags)
239 template<
typename UserType>
241 const std::string& description,
const std::unordered_set<std::string>& tags)
248 template<
typename UserType>
250 const std::string& description,
const std::unordered_set<std::string>& tags)
257 template<
typename UserType>
259 size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
266 template<
typename UserType>
268 size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
275 template<
typename UserType>
277 const std::string& description,
const std::unordered_set<std::string>& tags)
284 template<
typename UserType>
286 std::string unit,
size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
289 this->addTag(ChimeraTK::SystemTags::reverseRecovery);
static void incrementDataLossCounter(const std::string &name)
Increment counter for how many write() operations have overwritten unread data.
Accessor for array variables (i.e.
void setAndWrite(const std::vector< UserType > &newValue)
void writeIfDifferent(const std::vector< UserType > &newValue, VersionNumber versionNumber, DataValidity validity)=delete
ArrayAccessor(Module *owner, const std::string &name, VariableDirection direction, std::string unit, size_t nElements, UpdateMode mode, const std::string &description, const std::unordered_set< std::string > &tags={})
ArrayAccessor()=default
Default constructor creates a dysfunctional accessor (to be assigned with a real accessor later)
ArrayAccessor(ArrayAccessor< UserType > &&other) noexcept
Move constructor.
void replace(const ChimeraTK::NDRegisterAccessorAbstractor< UserType > &newAccessor)=delete
ArrayAccessor< UserType > & operator=(ArrayAccessor< UserType > &&other) noexcept
Move assignment.
ArrayAccessor< UserType > & operator=(ArrayAccessor< UserType > &other)=delete
bool write(ChimeraTK::VersionNumber versionNumber)=delete
bool writeDestructively()
void writeIfDifferent(const std::vector< UserType > &newValue)
void setAndWrite(const std::vector< UserType > &newValue, VersionNumber versionNumber)=delete
bool writeDestructively(ChimeraTK::VersionNumber versionNumber)=delete
Convenience class for output array accessors (always UpdateMode::push)
ArrayOutput(Module *owner, const std::string &name, std::string unit, size_t nElements, const std::string &description, const std::unordered_set< std::string > &tags={})
Convenience class for output array accessors with return channel ("read back") (always UpdateMode::pu...
ArrayOutputPushRB()=default
ArrayOutputReverseRecovery()=default
Adds features required for inversion of control to an accessor.
void deinit()
Early deinitialisation of stuff we cannot do in our destructor.
void init()
Late initialisation of stuff we cannot do in our constructor.
Base class for ApplicationModule and DeviceModule, to have a common interface for these module types.
Class describing a node of a variable network.
InvalidityTracer application module.
UpdateMode
Enum to define the update mode of variables.
Struct to define the direction of variables.