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