32 template<
typename UserType>
33 boost::shared_ptr<NDRegisterAccessor<UserType>>
getAccessor(boost::shared_ptr<LogicalNameMappingBackend> backend,
34 size_t numberOfWords,
size_t wordOffsetInRegister,
AccessModeFlags flags,
size_t pluginIndex) {
36 getAccessor_impl, UserType, backend, numberOfWords, wordOffsetInRegister, flags, pluginIndex);
40 boost::shared_ptr<LogicalNameMappingBackend>,
size_t,
size_t,
AccessModeFlags,
size_t));
73 virtual void openHook(
const boost::shared_ptr<LogicalNameMappingBackend>& backend) { std::ignore = backend; }
79 virtual void postParsingHook([[maybe_unused]]
const boost::shared_ptr<const LogicalNameMappingBackend>& backend) {}
104 template<
typename Derived>
142 template<
typename UserType,
typename TargetType>
144 boost::shared_ptr<LogicalNameMappingBackend>& backend,
148 template<
typename UserType>
150 boost::shared_ptr<LogicalNameMappingBackend>& backend,
size_t numberOfWords,
size_t wordOffsetInRegister,
163 const std::string& name,
const std::map<std::string, std::string>& parameters);
173 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
178 template<
typename UserType,
typename TargetType>
180 boost::shared_ptr<LogicalNameMappingBackend>& backend,
197 template<
typename UserType,
typename TargetType>
199 boost::shared_ptr<LogicalNameMappingBackend>& backend,
211 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
215 template<
typename UserType,
typename TargetType>
217 boost::shared_ptr<LogicalNameMappingBackend>& backend,
225 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
229 template<
typename UserType,
typename TargetType>
231 boost::shared_ptr<LogicalNameMappingBackend>& backend,
239 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
250 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
252 template<
typename UserType,
typename TargetType>
254 boost::shared_ptr<LogicalNameMappingBackend>& backend,
270 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
275 std::set<std::string> _tagsToAdd;
276 std::set<std::string> _tagsToRemove;
277 std::set<std::string> _tagsToSet;
284 [[maybe_unused]]
const std::map<std::string, std::string>& parameters)
293 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters);
295 template<
typename UserType,
typename TargetType>
297 boost::shared_ptr<LogicalNameMappingBackend>& backend,
303 std::list<std::string> _targets;
312 template<
typename Derived>
315 :
AccessorPluginBase(info), _needSharedTarget{shareTargetAccessors}, _pluginIndex(pluginIndex) {
321 template<
typename Derived>
322 template<
typename UserType,
typename TargetType>
326 if constexpr(std::is_same<UserType, TargetType>::value) {
338 template<
typename Derived>
339 template<
typename UserType>
341 boost::shared_ptr<LogicalNameMappingBackend>& backend,
size_t numberOfWords,
size_t wordOffsetInRegister,
343 boost::shared_ptr<NDRegisterAccessor<UserType>> decorated;
345 assert(_pluginIndex == pluginIndex);
348 auto type = getTargetDataType(
typeid(UserType));
351 "Access mode 'raw' is not supported for register '" + std::string(_info.getRegisterName()) +
"'");
357 if(_needSharedTarget) {
358 auto& map = boost::fusion::at_key<decltype(T)>(backend->sharedAccessorMap.table);
363 auto it = map.find(key);
364 if(it == map.end() || (target = it->second.accessor.lock()) ==
nullptr) {
366 target = backend->getRegisterAccessor_impl<
decltype(T)>(
367 _info.getRegisterName(), numberOfWords, wordOffsetInRegister, flags, pluginIndex + 1);
368 map[key].accessor = target;
372 target = backend->getRegisterAccessor_impl<
decltype(T)>(
373 _info.getRegisterName(), numberOfWords, wordOffsetInRegister, flags, pluginIndex + 1);
377 UndecoratedParams accessorParams(_info.registerName, numberOfWords, wordOffsetInRegister, flags);
378 decorated =
static_cast<Derived*
>(
this)->
template decorateAccessor<UserType>(backend, target, accessorParams);
381 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.
const bool _needSharedTarget
Deriving plugins should set this to true if they want to use interlocked access to the same target ac...
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, bool shareTargetAccessors=false)
The constructor of the plugin should also accept a 3rd argument: const std::map<std::string,...
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
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.
uint32_t dataInterpretationFractionalBits
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.
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.
std::pair< DeviceBackend *, RegisterPath > AccessorKey
Map of target accessors which are potentially shared across our accessors.
N-dimensional register accessor.
Class to store a register path name.
void setAltSeparator(const std::string &altSeparator)
set alternative separator.
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