33 template<
typename UserType>
34 boost::shared_ptr<NDRegisterAccessor<UserType>>
getAccessor(boost::shared_ptr<LogicalNameMappingBackend> backend,
35 size_t numberOfWords,
size_t wordOffsetInRegister,
AccessModeFlags flags,
size_t pluginIndex) {
37 getAccessor_impl, UserType, backend, numberOfWords, wordOffsetInRegister, flags, pluginIndex);
41 boost::shared_ptr<LogicalNameMappingBackend>,
size_t,
size_t,
AccessModeFlags,
size_t));
74 virtual void openHook(
const boost::shared_ptr<LogicalNameMappingBackend>& backend) { std::ignore = backend; }
80 virtual void postParsingHook([[maybe_unused]]
const boost::shared_ptr<const LogicalNameMappingBackend>& backend) {}
105 template<
typename Derived>
131 template<
typename UserType,
typename TargetType>
133 boost::shared_ptr<LogicalNameMappingBackend>& backend,
137 template<
typename UserType>
139 boost::shared_ptr<LogicalNameMappingBackend>& backend,
size_t numberOfWords,
size_t wordOffsetInRegister,
152 const std::string& name,
const std::map<std::string, std::string>& parameters);
162 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
167 template<
typename UserType,
typename TargetType>
169 boost::shared_ptr<LogicalNameMappingBackend>& backend,
186 template<
typename UserType,
typename TargetType>
188 boost::shared_ptr<LogicalNameMappingBackend>& backend,
200 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
204 template<
typename UserType,
typename TargetType>
206 boost::shared_ptr<LogicalNameMappingBackend>& backend,
214 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
218 template<
typename UserType,
typename TargetType>
220 boost::shared_ptr<LogicalNameMappingBackend>& backend,
230 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
234 template<
typename UserType,
typename TargetType>
236 boost::shared_ptr<LogicalNameMappingBackend>& backend,
240 std::optional<std::string> _engineeringUnit;
241 std::optional<std::string> _description;
248 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
259 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
261 template<
typename UserType,
typename TargetType>
263 boost::shared_ptr<LogicalNameMappingBackend>& backend,
279 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
284 std::set<std::string> _tagsToAdd;
285 std::set<std::string> _tagsToRemove;
286 std::set<std::string> _tagsToSet;
293 [[maybe_unused]]
const std::map<std::string, std::string>& parameters)
302 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
304 template<
typename UserType,
typename TargetType>
306 boost::shared_ptr<LogicalNameMappingBackend>& backend,
312 std::list<std::string> _targets;
321 template<
typename Derived>
329 template<
typename Derived>
330 template<
typename UserType,
typename TargetType>
334 if constexpr(std::is_same<UserType, TargetType>::value) {
346 template<
typename Derived>
347 template<
typename UserType>
349 boost::shared_ptr<LogicalNameMappingBackend>& backend,
size_t numberOfWords,
size_t wordOffsetInRegister,
351 boost::shared_ptr<NDRegisterAccessor<UserType>> decorated;
353 assert(_pluginIndex == pluginIndex);
356 auto type = getTargetDataType(
typeid(UserType));
359 "Access mode 'raw' is not supported for register '" + std::string(_info.getRegisterName()) +
"'");
365 target = backend->getRegisterAccessor_impl<
decltype(T)>(
366 _info.getRegisterName(), numberOfWords, wordOffsetInRegister, flags, pluginIndex + 1);
369 UndecoratedParams accessorParams(_info.registerName, numberOfWords, wordOffsetInRegister, flags);
370 decorated =
static_cast<Derived*
>(
this)->
template decorateAccessor<UserType>(backend, target, accessorParams);
373 decorated->setExceptionBackend(backend);
#define CALL_VIRTUAL_FUNCTION_TEMPLATE(functionName, templateArgument,...)
Execute the virtual function template call using the vtable defined with the DEFINE_VIRTUAL_FUNCTION_...
#define FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(functionName)
Fill the vtable of a virtual function template defined with DEFINE_VIRTUAL_FUNCTION_TEMPLATE.
Set of AccessMode flags with additional functionality for an easier handling.
bool has(AccessMode flag) const
Check if a certain flag is in the set.
Interface for backends to the register catalogue.
A class to describe which of the supported data types is used.
@ uint32
Unsigned 32 bit integer.
@ none
The data type/concept does not exist, e.g. there is no raw transfer (do not confuse with Void)
@ uint64
Unsigned 64 bit integer.
@ float64
Double precision float.
Base class for AccessorPlugins used by the LogicalNameMapping backend to store backends in lists.
virtual void exceptionHook()
Hook called when an exception is reported to the the backend via setException(), after the backend ha...
virtual void openHook(const boost::shared_ptr< LogicalNameMappingBackend > &backend)
Hook called when the backend is opened, at the end of the open() function after all backend work has ...
LNMBackendRegisterInfo _info
RegisterInfo describing the the target register for which this plugin instance should work.
boost::shared_ptr< NDRegisterAccessor< UserType > > getAccessor(boost::shared_ptr< LogicalNameMappingBackend > backend, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags, size_t pluginIndex)
Called by the backend when obtaining a register accessor.
virtual void postParsingHook(const boost::shared_ptr< const LogicalNameMappingBackend > &backend)
Hook called after the parsing of logical name map.
void updateRegisterInfo(BackendRegisterCatalogue< LNMBackendRegisterInfo > &)
Update the register info inside the catalogue if needed.
DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(getAccessor_impl, boost::shared_ptr< NDRegisterAccessor< T > >(boost::shared_ptr< LogicalNameMappingBackend >, size_t, size_t, AccessModeFlags, size_t))
virtual void doRegisterInfoUpdate()=0
Implementation of the plugin specific register information update.
virtual ~AccessorPluginBase()=default
virtual void closeHook()
Hook called when the backend is closed, at the beginning of the close() function when the device is s...
Base class for plugins that modify the behaviour of accessors in the logical name mapping backend.
size_t _pluginIndex
Index of the plugin instance within the stack of plugins on a particular register.
boost::shared_ptr< NDRegisterAccessor< UserType > > decorateAccessor(boost::shared_ptr< LogicalNameMappingBackend > &backend, boost::shared_ptr< NDRegisterAccessor< TargetType > > &target, const UndecoratedParams &accessorParams)
This function should be overridden by the plugin (yes, this is possible due to the CRTP).
boost::shared_ptr< NDRegisterAccessor< UserType > > getAccessor_impl(boost::shared_ptr< LogicalNameMappingBackend > &backend, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags, size_t pluginIndex)
This function is called by the backend.
AccessorPlugin(const LNMBackendRegisterInfo &info, size_t pluginIndex)
virtual DataType getTargetDataType(DataType userType) const
Return the data type for which the target accessor shall be obtained.
DataType getTargetDataType(DataType) const override
Return the data type for which the target accessor shall be obtained.
bool dataInterpretationIsSigned
int32_t dataInterpretationFractionalBits
boost::shared_ptr< NDRegisterAccessor< UserType > > decorateAccessor(boost::shared_ptr< LogicalNameMappingBackend > &backend, boost::shared_ptr< NDRegisterAccessor< TargetType > > &target, const UndecoratedParams &accessorParams)
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
boost::shared_ptr< NDRegisterAccessor< UserType > > decorateAccessor(boost::shared_ptr< LogicalNameMappingBackend > &backend, boost::shared_ptr< NDRegisterAccessor< TargetType > > &target, const UndecoratedParams &accessorParams)
FixedTagModifierPlugin(const LNMBackendRegisterInfo &info, size_t pluginIndex, const std::map< std::string, std::string > ¶meters)
ForcePollingRead Plugin: Forces a register to not allow setting the AccessMode::wait_for_new_data fla...
boost::shared_ptr< NDRegisterAccessor< UserType > > decorateAccessor(boost::shared_ptr< LogicalNameMappingBackend > &backend, boost::shared_ptr< NDRegisterAccessor< TargetType > > &target, const UndecoratedParams &accessorParams)
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
ForceReadOnly Plugin: Forces a register to be read only.
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
boost::shared_ptr< NDRegisterAccessor< UserType > > decorateAccessor(boost::shared_ptr< LogicalNameMappingBackend > &backend, boost::shared_ptr< NDRegisterAccessor< TargetType > > &target, const UndecoratedParams &accessorParams)
Monostable Trigger Plugin: Write value to target which falls back to another value after defined time...
DataType getTargetDataType(DataType) const override
Return the data type for which the target accessor shall be obtained.
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
boost::shared_ptr< NDRegisterAccessor< UserType > > decorateAccessor(boost::shared_ptr< LogicalNameMappingBackend > &backend, boost::shared_ptr< NDRegisterAccessor< TargetType > > &target, const UndecoratedParams &accessorParams)
Multiplier Plugin: Multiply register's data with a constant factor.
DataType getTargetDataType(DataType) const override
Return the data type for which the target accessor shall be obtained.
boost::shared_ptr< NDRegisterAccessor< UserType > > decorateAccessor(boost::shared_ptr< LogicalNameMappingBackend > &backend, boost::shared_ptr< NDRegisterAccessor< TargetType > > &target, const UndecoratedParams &accessorParams)
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
SetDescription Plugin: Overwrites the engineering unit and/or description of the accessor without cha...
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
boost::shared_ptr< NDRegisterAccessor< UserType > > decorateAccessor(boost::shared_ptr< LogicalNameMappingBackend > &backend, boost::shared_ptr< NDRegisterAccessor< TargetType > > &target, const UndecoratedParams &accessorParams)
TagModifier Plugin: Manipulate the tags in the register catalogue.
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
TypeHintModifier Plugin: Change the catalogue type of the mapped register.
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
RegisterInfo structure for the LogicalNameMappingBackend.
N-dimensional register accessor.
Exception thrown when a logic error has occured.
boost::shared_ptr< AccessorPluginBase > makePlugin(LNMBackendRegisterInfo info, size_t pluginIndex, const std::string &name, const std::map< std::string, std::string > ¶meters)
Factory function for accessor plugins.
void callForType(const std::type_info &type, LAMBDATYPE lambda)
Helper function for running code which uses some compile-time type that is specified at runtime as a ...
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...
Helper struct to hold extra parameters needed by some plugins, used in decorateAccessor()
UndecoratedParams(const std::string &name, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags)
size_t _wordOffsetInRegister