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>
153 template<
typename UserType>
163 template<
typename UserType>
165 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
166 bool dataLoss = ChimeraTK::ScalarRegisterAccessor<UserType>::write(versionNumber);
175 template<
typename UserType>
177 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
178 bool dataLoss = ChimeraTK::ScalarRegisterAccessor<UserType>::writeDestructively(versionNumber);
187 template<
typename UserType>
189 if(this->get()->accessData(0, 0) != newValue || this->
template checkMetadataWriteDifference<UserType>()) {
190 setAndWrite(newValue);
196 template<
typename UserType>
204 template<
typename UserType>
206 std::string unit,
UpdateMode mode,
const std::string& description,
const std::unordered_set<std::string>& tags)
208 owner, name, direction, unit, 1, mode, description, &typeid(UserType), tags) {
215 template<
typename UserType>
217 const std::string& description,
const std::unordered_set<std::string>& tags)
224 template<
typename UserType>
226 const std::string& description,
const std::unordered_set<std::string>& tags)
233 template<
typename UserType>
235 const std::string& description,
const std::unordered_set<std::string>& tags)
242 template<
typename UserType>
244 const std::string& description,
const std::unordered_set<std::string>& tags)
251 template<
typename UserType>
253 const std::string& description,
const std::unordered_set<std::string>& tags)
260 template<
typename UserType>
262 std::string unit,
const std::string& description,
const std::unordered_set<std::string>& tags)
265 this->addTag(ChimeraTK::SystemTags::reverseRecovery);
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.
UpdateMode
Enum to define the update mode of variables.
Struct to define the direction of variables.