ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
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
17namespace xmlpp {
18 class Node;
19 class Element;
20} // namespace xmlpp
21
22namespace 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
Interface for backends to the register catalogue.
Logical name map: store information from xlmap file and provide it to the LogicalNameMappingBackend a...
std::map< std::string, LNMVariable > & _variables
Reference to the variables map inside the LNM backend.
RegisterPath currentModule
current register path in the map
BackendRegisterCatalogue< LNMBackendRegisterInfo > parseFile(const std::string &fileName)
parse the given XML file
LogicalNameMapParser(std::map< std::string, std::string > parameters, std::map< std::string, LNMVariable > &variables)
Constructor: parse map from XML file.
std::vector< ValueType > getValueVectorFromXmlSubnode(const xmlpp::Node *node, const std::string &subnodeName, BackendRegisterCatalogue< LNMBackendRegisterInfo > const &catalogue)
std::string _fileName
file name of the logical map
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.
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
std::map< std::string, std::string > _parameters
actual register info map (register name to target information)
void parsingError(const xmlpp::Node *node, const std::string &message)
throw a parsing error with more information
Class to store a register path name.
STL namespace.