ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
LNMAccessorPlugin.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
6#include "LNMMathPlugin.h"
7#include "SystemTags.h"
8
9#include <boost/make_shared.hpp>
10
11namespace ChimeraTK::LNMBackend {
12
13 /********************************************************************************************************************/
14
15 boost::shared_ptr<AccessorPluginBase> makePlugin(LNMBackendRegisterInfo info, size_t pluginIndex,
16 const std::string& name, const std::map<std::string, std::string>& parameters) {
17 if(name == "multiply") {
18 return boost::make_shared<MultiplierPlugin>(info, pluginIndex, parameters);
19 }
20 if(name == "math") {
21 return boost::make_shared<MathPlugin>(info, pluginIndex, parameters);
22 }
23 if(name == "monostableTrigger") {
24 return boost::make_shared<MonostableTriggerPlugin>(info, pluginIndex, parameters);
25 }
26 if(name == "forceReadOnly") {
27 return boost::make_shared<ForceReadOnlyPlugin>(info, pluginIndex, parameters);
28 }
29 if(name == "forcePollingRead") {
30 return boost::make_shared<ForcePollingReadPlugin>(info, pluginIndex, parameters);
31 }
32 if(name == "typeHintModifier") {
33 return boost::make_shared<TypeHintModifierPlugin>(info, pluginIndex, parameters);
34 }
35 if(name == "doubleBuffer") {
36 return boost::make_shared<DoubleBufferPlugin>(info, pluginIndex, parameters);
37 }
38 if(name == "bitRange") {
39 return boost::make_shared<BitRangeAccessPlugin>(info, pluginIndex, parameters);
40 }
41 if(name == "tagModifier") {
42 return boost::make_shared<TagModifierPlugin>(info, pluginIndex, parameters);
43 }
44 if(name == "isStatusOutput") {
45 return boost::make_shared<FixedTagModifierPlugin<ChimeraTK::SystemTags::statusOutput>>(
46 info, pluginIndex, parameters);
47 }
48 if(name == "hasReverseRecovery") {
49 return boost::make_shared<FixedTagModifierPlugin<ChimeraTK::SystemTags::reverseRecovery>>(
50 info, pluginIndex, parameters);
51 }
52 if(name == "fanOut") {
53 return boost::make_shared<FanOutPlugin>(info, pluginIndex, parameters);
54 }
55 throw ChimeraTK::logic_error("LogicalNameMappingBackend: Unknown plugin type '" + name + "'.");
56 }
57
59 // do not hold shared pointers to other plugins or even to yourself inside a plugin.
60 _info.plugins.clear();
61 }
62
64 // First update the info so we have the latest version from the catalogue.
65 // At this point we also get a list of shared_ptrs of all plugins inside the info object.
67 // Do the actual info modifications as implemented by the plugin.
69 // Write the modifications back to the catalogue (still including plugins).
70 catalogue.modifyRegister(_info);
71 // Remove the list of plugins from the copy inside the plugin, which otherwise would hold a shared_ptr to itself.
72 // For abstraction reasons it also must not know about other plugins, so it is safe to remove the whole list.
73 _info.plugins.clear();
74 }
75
76} // namespace ChimeraTK::LNMBackend
Interface for backends to the register catalogue.
void modifyRegister(const BackendRegisterInfo &registerInfo)
Replaces the register information for the matching register.
virtual BackendRegisterInfo getBackendRegister(const RegisterPath &registerPathName) const
Note: Override this function if backend has "hidden" registers which are not added to the map and hen...
LNMBackendRegisterInfo _info
RegisterInfo describing the the target register for which this plugin instance should work.
void updateRegisterInfo(BackendRegisterCatalogue< LNMBackendRegisterInfo > &)
Update the register info inside the catalogue if needed.
AccessorPluginBase(const LNMBackendRegisterInfo &info)
virtual void doRegisterInfoUpdate()=0
Implementation of the plugin specific register information update.
RegisterInfo structure for the LogicalNameMappingBackend.
RegisterPath name
Name of the register.
std::vector< boost::shared_ptr< LNMBackend::AccessorPluginBase > > plugins
List of accessor plugins enabled for this register.
Exception thrown when a logic error has occured.
Definition Exception.h:51
boost::shared_ptr< AccessorPluginBase > makePlugin(LNMBackendRegisterInfo info, size_t pluginIndex, const std::string &name, const std::map< std::string, std::string > &parameters)
Factory function for accessor plugins.