ChimeraTK-DeviceAccess 03.29.00
Loading...
Searching...
No Matches
LNMSetDescriptionPlugin.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#include "LNMAccessorPlugin.h"
6
7#include <boost/make_shared.hpp>
8
9namespace ChimeraTK::LNMBackend {
10
11 /********************************************************************************************************************/
12
14 const LNMBackendRegisterInfo& info, size_t pluginIndex, const std::map<std::string, std::string>& parameters)
15 : AccessorPlugin(info, pluginIndex) {
16 auto unitIt = parameters.find("engineeringUnit");
17 if(unitIt != parameters.end()) {
18 _engineeringUnit = unitIt->second;
19 }
20 auto descriptionIt = parameters.find("description");
21 if(descriptionIt != parameters.end()) {
22 _description = descriptionIt->second;
23 }
24 }
25
26 /********************************************************************************************************************/
27
29 // Update the catalogue info so tooling can see the overwritten values before creating an accessor.
30 // Only overwrite the fields that were explicitly provided via the plugin parameters.
31 if(_engineeringUnit) {
32 _info.engineeringUnit = *_engineeringUnit;
33 }
34 if(_description) {
35 _info.description = *_description;
36 }
37 }
38
39 /********************************************************************************************************************/
40
41 template<typename UserType, typename TargetType>
42 boost::shared_ptr<NDRegisterAccessor<UserType>> SetDescriptionPlugin::decorateAccessor(
43 boost::shared_ptr<LogicalNameMappingBackend>&, boost::shared_ptr<NDRegisterAccessor<TargetType>>& target,
44 const UndecoratedParams&) {
45 if constexpr(std::is_same<UserType, TargetType>::value) {
46 if(_engineeringUnit) {
47 target->setUnit(*_engineeringUnit);
48 }
49 if(_description) {
50 target->setDescription(*_description);
51 }
52 return target;
53 }
54
55 assert(false); // SetDescriptionPlugin does not change the user type
56
57 return {};
58 }
59
60} // namespace ChimeraTK::LNMBackend
LNMBackendRegisterInfo _info
RegisterInfo describing the the target register for which this plugin instance should work.
Base class for plugins that modify the behaviour of accessors in the logical name mapping backend.
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)
SetDescriptionPlugin(const LNMBackendRegisterInfo &info, size_t pluginIndex, const std::map< std::string, std::string > &parameters)
RegisterInfo structure for the LogicalNameMappingBackend.
std::string description
Custom description overwritten by plugins (e.g.
std::string engineeringUnit
Custom engineering unit overwritten by plugins (e.g.
N-dimensional register accessor.
Helper struct to hold extra parameters needed by some plugins, used in decorateAccessor()