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;
59 UpdateMode mode,
const std::string& description,
const std::unordered_set<std::string>& tags = {});
69 template<
typename UserType>
72 const std::unordered_set<std::string>& tags = {});
80 template<
typename UserType>
83 const std::unordered_set<std::string>& tags = {});
85 void read() { this->readLatest(); }
92 template<
typename UserType>
94 ScalarOutput(
Module* owner,
const std::string& name, std::string unit,
const std::string& description,
95 const std::unordered_set<std::string>& tags = {});
103 template<
typename UserType>
106 const std::unordered_set<std::string>& tags = {});
114 template<
typename UserType>
117 const std::unordered_set<std::string>& tags = {});
125 template<
typename UserType>
128 const std::string& description,
const std::unordered_set<std::string>& tags = {});
138 template<
typename UserType>
145 template<
typename UserType>
155 template<
typename UserType>
157 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
158 bool dataLoss = ChimeraTK::ScalarRegisterAccessor<UserType>::write(versionNumber);
167 template<
typename UserType>
169 auto versionNumber = this->getOwner()->getCurrentVersionNumber();
170 bool dataLoss = ChimeraTK::ScalarRegisterAccessor<UserType>::writeDestructively(versionNumber);
179 template<
typename UserType>
184 auto* targetMetaDataPropagatingDecorator =
186 assert(targetMetaDataPropagatingDecorator !=
nullptr);
193 if(this->get()->accessData(0, 0) != newValue || this->getVersionNumber() == VersionNumber(
nullptr) ||
194 targetMetaDataPropagatingDecorator->getTargetValidity() != this->getOwner()->getDataValidity()) {
195 setAndWrite(newValue);
201 template<
typename UserType>
209 template<
typename UserType>
211 std::string unit,
UpdateMode mode,
const std::string& description,
const std::unordered_set<std::string>& tags)
213 owner, name, direction, unit, 1, mode, description, &typeid(UserType), tags) {}
218 template<
typename UserType>
220 const std::string& description,
const std::unordered_set<std::string>& tags)
227 template<
typename UserType>
229 const std::string& description,
const std::unordered_set<std::string>& tags)
236 template<
typename UserType>
238 const std::string& description,
const std::unordered_set<std::string>& tags)
245 template<
typename UserType>
247 const std::string& description,
const std::unordered_set<std::string>& tags)
254 template<
typename UserType>
256 const std::string& description,
const std::unordered_set<std::string>& tags)
263 template<
typename UserType>
265 std::string unit,
const std::string& description,
const std::unordered_set<std::string>& tags)
268 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.
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 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
Class describing a node of a variable network.
InvalidityTracer application module.
UpdateMode
Enum to define the update mode of variables.
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()
Struct to define the direction of variables.