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 = {});
157 template<
typename UserType>
161 const std::string& description,
const std::unordered_set<std::string>& tags = {});
169 template<
typename UserType>
173 const std::string& description,
const std::unordered_set<std::string>& tags = {});
175 void read() { this->readLatest(); }
185 template<
typename UserType>
192 template<
typename UserType>
202 template<
typename UserType>
204 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
205 bool dataLoss = ChimeraTK::OneDRegisterAccessor<UserType>::write(versionNumber);
214 template<
typename UserType>
216 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
217 bool dataLoss = ChimeraTK::OneDRegisterAccessor<UserType>::writeDestructively(versionNumber);
226 template<
typename UserType>
228 if(!std::equal(newValue.begin(), newValue.end(), this->get()->accessChannel(0).begin()) ||
229 this->template checkMetadataWriteDifference<UserType>()) {
230 setAndWrite(newValue);
236 template<
typename UserType>
244 template<
typename UserType>
246 std::string unit,
size_t nElements,
UpdateMode mode,
const std::string& description,
247 const std::unordered_set<std::string>& tags)
249 owner, name, direction, unit, nElements, mode, description, &typeid(UserType), tags) {
256 template<
typename UserType>
258 const std::string& description,
const std::unordered_set<std::string>& tags)
265 template<
typename UserType>
267 const std::string& description,
const std::unordered_set<std::string>& tags)
274 template<
typename UserType>
276 const std::string& description,
const std::unordered_set<std::string>& tags)
283 template<
typename UserType>
285 size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
292 template<
typename UserType>
294 size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
301 template<
typename UserType>
303 const std::string& description,
const std::unordered_set<std::string>& tags)
310 template<
typename UserType>
312 std::string unit,
size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
315 this->addTag(ChimeraTK::SystemTags::reverseRecovery);
320 template<
typename UserType>
322 std::string unit,
size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
330 template<
typename UserType>
332 std::string unit,
size_t nElements,
const std::string& description,
const std::unordered_set<std::string>& tags)
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.
constexpr char noInitialValueReadTag[]
System tag to mark an accessor which should be excluded from the initial value read during applicatio...
UpdateMode
Enum to define the update mode of variables.
Struct to define the direction of variables.