ChimeraTK-DeviceAccess  03.18.00
LogicalNameMapParser.h
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 #pragma once
4 
6 #include "LNMAccessorPlugin.h"
8 #include "LNMVariable.h"
9 #include "RegisterPath.h"
10 
11 #include <boost/shared_ptr.hpp>
12 
13 #include <map>
14 #include <utility>
15 
16 // forward declaration
17 namespace xmlpp {
18  class Node;
19  class Element;
20 } // namespace xmlpp
21 
22 namespace ChimeraTK {
23 
27  public:
29  LogicalNameMapParser(std::map<std::string, std::string> parameters, std::map<std::string, LNMVariable>& variables)
30  : _parameters(std::move(parameters)), _variables(variables) {}
31 
34  // BackendRegisterCatalogue<LNMBackendRegisterInfo> _catalogue;
35 
36  protected:
39  void parseElement(const RegisterPath& currentPath, const xmlpp::Element* element,
41 
43  [[noreturn]] void parsingError(const xmlpp::Node* node, const std::string& message);
44 
46  template<typename ValueType>
47  ValueType getValueFromXmlSubnode(const xmlpp::Node* node, const std::string& subnodeName,
48  BackendRegisterCatalogue<LNMBackendRegisterInfo> const& catalogue, bool hasDefault = false,
49  ValueType defaultValue = ValueType());
50  template<typename ValueType>
51  std::vector<ValueType> getValueVectorFromXmlSubnode(const xmlpp::Node* node, const std::string& subnodeName,
53 
55  std::string _fileName;
56 
59 
61  // BackendRegisterCatalogue<LNMBackendRegisterInfo> _catalogue;
62  // LNMRegisterCatalogue _catalogue;
63 
65  std::map<std::string, std::string> _parameters;
66 
68  std::map<std::string, LNMVariable>& _variables;
69  };
70 
71  template<>
72  std::string LogicalNameMapParser::getValueFromXmlSubnode<std::string>(const xmlpp::Node* node,
73  const std::string& subnodeName, BackendRegisterCatalogue<LNMBackendRegisterInfo> const& catalogue,
74  bool hasDefault, std::string defaultValue);
75 
76 } // namespace ChimeraTK
ChimeraTK::LogicalNameMapParser::_parameters
std::map< std::string, std::string > _parameters
actual register info map (register name to target information)
Definition: LogicalNameMapParser.h:65
ChimeraTK::LogicalNameMapParser::parseElement
void parseElement(const RegisterPath &currentPath, const xmlpp::Element *element, BackendRegisterCatalogue< LNMBackendRegisterInfo > &catalogue)
called inside parseFile() to parse an XML element and its sub-elements recursively
Definition: LogicalNameMapParser.cc:294
LNMVariable.h
ChimeraTK::LogicalNameMapParser::_variables
std::map< std::string, LNMVariable > & _variables
Reference to the variables map inside the LNM backend.
Definition: LogicalNameMapParser.h:68
BackendRegisterCatalogue.h
ChimeraTK::LogicalNameMapParser::currentModule
RegisterPath currentModule
current register path in the map
Definition: LogicalNameMapParser.h:58
ChimeraTK::LogicalNameMapParser::parsingError
void parsingError(const xmlpp::Node *node, const std::string &message)
throw a parsing error with more information
Definition: LogicalNameMapParser.cc:447
ChimeraTK::LogicalNameMapParser
Logical name map: store information from xlmap file and provide it to the LogicalNameMappingBackend a...
Definition: LogicalNameMapParser.h:26
ChimeraTK::BackendRegisterCatalogue
Interface for backends to the register catalogue.
Definition: BackendRegisterCatalogue.h:70
xmlpp
Definition: LogicalNameMapParser.h:17
ChimeraTK::LogicalNameMapParser::getValueFromXmlSubnode
ValueType getValueFromXmlSubnode(const xmlpp::Node *node, const std::string &subnodeName, BackendRegisterCatalogue< LNMBackendRegisterInfo > const &catalogue, bool hasDefault=false, ValueType defaultValue=ValueType())
Build a Value object for a given subnode.
ChimeraTK::LogicalNameMapParser::LogicalNameMapParser
LogicalNameMapParser(std::map< std::string, std::string > parameters, std::map< std::string, LNMVariable > &variables)
Constructor: parse map from XML file.
Definition: LogicalNameMapParser.h:29
ChimeraTK::LogicalNameMapParser::parseFile
BackendRegisterCatalogue< LNMBackendRegisterInfo > parseFile(const std::string &fileName)
parse the given XML file
Definition: LogicalNameMapParser.cc:261
ChimeraTK::RegisterPath
Class to store a register path name.
Definition: RegisterPath.h:16
ChimeraTK::LogicalNameMapParser::getValueVectorFromXmlSubnode
std::vector< ValueType > getValueVectorFromXmlSubnode(const xmlpp::Node *node, const std::string &subnodeName, BackendRegisterCatalogue< LNMBackendRegisterInfo > const &catalogue)
LNMBackendRegisterInfo.h
ChimeraTK
Definition: DummyBackend.h:16
LNMAccessorPlugin.h
ChimeraTK::LogicalNameMapParser::_fileName
std::string _fileName
file name of the logical map
Definition: LogicalNameMapParser.h:55
RegisterPath.h