Skip to content
Snippets Groups Projects
XMLGeneratorVisitor.h 1.83 KiB
Newer Older
// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once

Jens Georg's avatar
Jens Georg committed
#include "ConnectionMaker.h"

#include <memory>
#include <string>

// Forward declarations
namespace xmlpp {
  class Document;
  class Element;
} // namespace xmlpp

namespace ChimeraTK {
Jens Georg's avatar
Jens Georg committed
   * @brief Generate XML representation of variables
Jens Georg's avatar
Jens Georg committed
   * This class is responsible for generating the XML representation of the variables in an Application.
Jens Georg's avatar
Jens Georg committed
  class XMLGenerator : NetworkVisitor {
    explicit XMLGenerator(Application& app);
Jens Georg's avatar
Jens Georg committed
    ~XMLGenerator() = default;
Jens Georg's avatar
Jens Georg committed
    void run();
    void save(const std::string& fileName);
Jens Georg's avatar
Jens Georg committed
    using NetworkVisitor::_triggerNetworks;

    std::shared_ptr<xmlpp::Document> _doc;
    xmlpp::Element* _rootElement;
Jens Georg's avatar
Jens Georg committed

    NetworkInformation generateXMLNetwork(Model::ProcessVariableProxy& proxy);

    /**
     * @brief generate the XML representation of @node
     * @param net The currently processed network meta-data
     * @param node The network node
     */
    void generateXMLForNode(NetworkInformation& net, const VariableNetworkNode& node);

    /**
     * @brief generate XML list of peers
     * @param connectedModules XML node to fill
     * @param nodeList list of peer nodes
     */
    static void generatePeerList(xmlpp::Element* connectedModules, const std::list<VariableNetworkNode>& nodeList);
Jens Georg's avatar
Jens Georg committed

    /**
     * @brief convert std::type_info to user-readable string
     * @param type std::type_info
     * @return the string representation of type or {unknown} if not mappable
     */
    static std::string mapTypeToName(const std::type_info* type);
  /********************************************************************************************************************/

} // namespace ChimeraTK