dcxmlmodelmapping.h
4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef OSDEV_COMPONENTS_DCXMLMODELMAPPING_H
#define OSDEV_COMPONENTS_DCXMLMODELMAPPING_H
#include "dcxmletlnetwork.h"
#include "dcxmletlservices.h"
#include <QHash>
#include <QObject>
#include <QSharedPointer>
#include <QStringList>
#include <memory>
namespace osdev {
namespace components {
/*! \brief This component locates any configuration information needed
* to initialize the application and its components.
* Parses this information and make it available to other
* components that need it.
*
* This component is implemented as a singleton. XML has the
* "habit" of expand approx. 15 times the file size so with this
* in mind, it is more future proof to load this only once into memory.
*/
/*
* ________________________________________
* / History, n.: \
* | |
* | Papa Hegel he say that all we learn |
* | from history is that we |
* | learn nothing from history. I know |
* | people who can't even learn from |
* | what happened this morning. Hegel must |
* | have been taking the long view. |
* | |
* | -- Chad C. Mulligan, "The Hipcrime |
* \ Vocab" /
* ----------------------------------------
* \
* \
* .--.
* |o_o |
* |:_/ |
* // \ \
* (| | )
* /'\_ _/`\
* \___)=(___/
*/
using network_container = QHash<QString, QSharedPointer<DcXmlEtlNetwork>>;
class DcXmlModelMapping
{
public:
/// @return the one and only instance of the config object.
static DcXmlModelMapping& Instance();
// =========================================================
/// The constructor
DcXmlModelMapping();
/// The destructor
virtual ~DcXmlModelMapping();
/// Deleted copy-constructor
DcXmlModelMapping(const DcXmlModelMapping&) = delete;
/// Deleted assignment constructor
DcXmlModelMapping& operator=(const DcXmlModelMapping&) = delete;
/// Deleted move-constructor
DcXmlModelMapping(DcXmlModelMapping&&) = delete;
/// Deleted move-operator
DcXmlModelMapping& operator=(DcXmlModelMapping&&) = delete;
// ==========================================================
/// @brief Loads the configuration from the given filename
/// @param fileName - The configuration file in XML format.
bool loadConfiguration(const QString& configDir, const QString& fileName);
bool loadConfiguration(const QString& fileName);
/*! @brief Retrieve a list of services configured in the ModelMapper configuration
* @return A StringList of all serviceNames.
*/
QStringList getServices() const;
QString getServiceId(const QString& _serviceName) const;
QStringList getNetworksOfService(const QString& _serviceName) const;
QList<QSharedPointer<ObjectData>> getObjectsOfNetwork(const QString& _networkName) const;
Connections getConnectionsOfNetwork(const QString& _networkName) const;
QStringList getInputVariables(const QString& _networkName) const;
QStringList getOutputVariables(const QString& _networkName) const;
QThread::Priority getPrioByNetworkName(const QString& _networkName) const;
private:
void cleanInternals(); ///< Cleanup the internal structures and destroy all objects.
QSharedPointer<DcXmlEtlNetwork> findNetworkByName(const QString& networkName) const; ///< Find the object that contains a config with this name.
static std::unique_ptr<DcXmlModelMapping> s_instance; ///< Instantiated ModelMapper Configuration object.
// Internal pointers......
QSharedPointer<DcXmlEtlServices> m_services; ///< Instantiated Services Configuration object.
network_container m_networks; ///< Collection of instantiated network configuration objects.
};
} // namespace components
} // namespace osdev
#endif // OSDEV_COMPONENTS_DCXMLMODELMAPPING_H