8#include <ChimeraTK/ScalarRegisterAccessor.h>
9#include <ChimeraTK/SystemTags.h>
11#include <boost/smart_ptr/shared_ptr.hpp>
12#include <boost/thread.hpp>
24 template<
typename UserType>
29 void replace(
const ChimeraTK::NDRegisterAccessorAbstractor<UserType>& newAccessor) =
delete;
32 using ChimeraTK::ScalarRegisterAccessor<UserType>::operator=;
40 bool write(ChimeraTK::VersionNumber versionNumber) =
delete;
42 void writeIfDifferent(UserType newValue, VersionNumber versionNumber, DataValidity validity) =
delete;
43 void setAndWrite(UserType newValue, VersionNumber versionNumber) =
delete;
61 UpdateMode mode,
const std::string& description,
const std::unordered_set<std::string>& tags = {});
71 template<
typename UserType>
75 const std::unordered_set<std::string>& tags = {});
83 template<
typename UserType>
87 const std::unordered_set<std::string>& tags = {});
89 void read() { this->readLatest(); }
96 template<
typename UserType>
99 ScalarOutput(
Module* owner,
const std::string& name, std::string unit,
const std::string& description,
100 const std::unordered_set<std::string>& tags = {});
108 template<
typename UserType>
112 const std::unordered_set<std::string>& tags = {});
120 template<
typename UserType>
124 const std::unordered_set<std::string>& tags = {});
132 template<
typename UserType>
136 const std::string& description,
const std::unordered_set<std::string>& tags = {});
146 template<
typename UserType>
150 const std::string& description,
const std::unordered_set<std::string>& tags = {});
158 template<
typename UserType>
162 const std::string& description,
const std::unordered_set<std::string>& tags = {});
164 void read() { this->readLatest(); }
174 template<
typename UserType>
181 template<
typename UserType>
191 template<
typename UserType>
193 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
194 bool dataLoss = ChimeraTK::ScalarRegisterAccessor<UserType>::write(versionNumber);
203 template<
typename UserType>
205 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
206 bool dataLoss = ChimeraTK::ScalarRegisterAccessor<UserType>::writeDestructively(versionNumber);
215 template<
typename UserType>
217 if(this->get()->accessData(0, 0) != newValue || this->
template checkMetadataWriteDifference<UserType>()) {
218 setAndWrite(newValue);
224 template<
typename UserType>
232 template<
typename UserType>
234 std::string unit,
UpdateMode mode,
const std::string& description,
const std::unordered_set<std::string>& tags)
236 owner, name, direction, unit, 1, mode, description, &typeid(UserType), tags) {
243 template<
typename UserType>
245 const std::string& description,
const std::unordered_set<std::string>& tags)
252 template<
typename UserType>
254 const std::string& description,
const std::unordered_set<std::string>& tags)
261 template<
typename UserType>
263 const std::string& description,
const std::unordered_set<std::string>& tags)
270 template<
typename UserType>
272 const std::string& description,
const std::unordered_set<std::string>& tags)
279 template<
typename UserType>
281 const std::string& description,
const std::unordered_set<std::string>& tags)
288 template<
typename UserType>
290 std::string unit,
const std::string& description,
const std::unordered_set<std::string>& tags)
293 this->addTag(ChimeraTK::SystemTags::reverseRecovery);
298 template<
typename UserType>
300 std::string unit,
const std::string& description,
const std::unordered_set<std::string>& tags)
308 template<
typename UserType>
310 std::string unit,
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.
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.
Accessor for scalar variables (i.e.
bool write(ChimeraTK::VersionNumber versionNumber)=delete
bool writeDestructively(ChimeraTK::VersionNumber versionNumber)=delete
bool writeDestructively()
void setAndWrite(UserType newValue)
void writeIfDifferent(UserType newValue, VersionNumber versionNumber, DataValidity validity)=delete
ScalarAccessor(ScalarAccessor< UserType > &&other) noexcept
Move constructor.
ScalarAccessor< UserType > & operator=(ScalarAccessor< UserType > &&other) noexcept
Move assignment.
void writeIfDifferent(UserType newValue)
ScalarAccessor< UserType > & operator=(ScalarAccessor< UserType > &other)=delete
void setAndWrite(UserType newValue, VersionNumber versionNumber)=delete
ScalarAccessor()=default
Default constructor creates a dysfunctional accessor (to be assigned with a real accessor later)
ScalarAccessor(Module *owner, const std::string &name, VariableDirection direction, std::string unit, UpdateMode mode, const std::string &description, const std::unordered_set< std::string > &tags={})
void replace(const ChimeraTK::NDRegisterAccessorAbstractor< UserType > &newAccessor)=delete
Convenience class for output scalar accessors (always UpdateMode::push)
Convenience class for output scalar accessors with return channel ("read back") (always UpdateMode::p...
ScalarOutputPushRB(Module *owner, const std::string &name, std::string unit, const std::string &description, const std::unordered_set< std::string > &tags={})
Convenience class for output scalar accessors with return channel ("read back") (always UpdateMode::p...
ScalarOutputReverseRecovery()
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.