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;
59 size_t nElements,
UpdateMode mode,
const std::string& description,
60 const std::unordered_set<std::string>& tags = {});
69 template<
typename UserType>
72 const std::string& description,
const std::unordered_set<std::string>& tags = {});
80 template<
typename UserType>
83 const std::string& description,
const std::unordered_set<std::string>& tags = {});
85 void read() { this->readLatest(); }
92 template<
typename UserType>
95 const std::string& description,
const std::unordered_set<std::string>& tags = {});
104 template<
typename UserType>
107 const std::string& description,
const std::unordered_set<std::string>& tags = {});
116 template<
typename UserType>
119 const std::string& description,
const std::unordered_set<std::string>& tags = {});
127 template<
typename UserType>
129 [[deprecated]]
ArrayOutputRB(
Module* owner,
const std::string& name, std::string unit,
size_t nElements,
130 const std::string& description,
const std::unordered_set<std::string>& tags = {});
137 template<
typename UserType>
140 const std::string& description,
const std::unordered_set<std::string>& tags = {});
150 template<
typename UserType>
157 template<
typename UserType>
167 template<
typename UserType>
169 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
170 bool dataLoss = ChimeraTK::OneDRegisterAccessor<UserType>::write(versionNumber);
179 template<
typename UserType>
181 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
182 bool dataLoss = ChimeraTK::OneDRegisterAccessor<UserType>::writeDestructively(versionNumber);
191 template<
typename UserType>
196 auto* targetMetaDataPropagatingDecorator =
198 assert(targetMetaDataPropagatingDecorator !=
nullptr);
205 if(!std::equal(newValue.begin(), newValue.end(), this->get()->accessChannel(0).begin()) ||
206 this->getVersionNumber() == VersionNumber(
nullptr) ||
207 targetMetaDataPropagatingDecorator->getTargetValidity() != this->getOwner()->getDataValidity()) {
208 setAndWrite(newValue);
214 template<
typename UserType>
222 template<
typename UserType>
224 std::string unit,
size_t nElements,
UpdateMode mode,
const std::string& description,
225 const std::unordered_set<std::string>& tags)
227 owner, name, direction, unit, nElements, mode, description, &typeid(UserType), tags) {}
232 template<
typename UserType>
234 const std::string& description,
const std::unordered_set<std::string>& tags)
241 template<
typename UserType>
243 const std::string& description,
const std::unordered_set<std::string>& tags)
250 template<
typename UserType>
252 const std::string& description,
const std::unordered_set<std::string>& tags)
259 template<
typename UserType>
261 size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
268 template<
typename UserType>
270 size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
277 template<
typename UserType>
279 const std::string& description,
const std::unordered_set<std::string>& tags)
286 template<
typename UserType>
288 std::string unit,
size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
291 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 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
Adds features required for inversion of control to an accessor.
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.
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
Struct to define the direction of variables.