MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Configuration.hpp
1 #pragma once
2 
3 #include "Export.hpp"
4 #include "Graph.hpp"
5 
6 #include <QSettings>
7 
8 namespace Showcase
9 {
10 
12  enum class AppType {
13  PUBLIC,
14  PRIVATE
15  };
16 
23  {
24  GraphNode uiRoot;
25  GraphNode theme;
26  GraphNode systemConfiguration;
27  int id;
29  };
30  typedef std::shared_ptr<RunConfiguration> RunConfigurationPtr;
31 
32  struct ScheduleConfig
33  {
34  GraphNode node;
35  int id;
36  };
37  typedef std::shared_ptr<ScheduleConfig> ScheduleConfigPtr;
38 
47  class SHOWCASE_API Configuration
48  {
50  public:
51  ~Configuration();
52  const QStringList& componentPaths() const;
53 
54  static std::shared_ptr<Configuration> defaultConfiguration();
55  static std::shared_ptr<Configuration> parse(const QString& filePath);
56  static std::shared_ptr<Configuration> instance(const QString& path="");
57 
60 
61  void setRunConfiguration(const QString& runConfigurationName);
62  QString runConfiguration();
63 
64  RunConfigurationPtr currentRunConfiguration(bool printHelp=true);
65 
66  const QString& controlHostUrl() const;
67 
68  std::map<QString, RunConfigurationPtr> getRunConfs() const;
69 
70  const QString& runConfLocation() const;
71  void setRunConfLocation(const QString& location);
72 
73  void setSchedule(const QString & name);
74  ScheduleConfigPtr currentSchedule();
75 
76  private:
77  Configuration();
78 
79  static std::map<QString, RunConfigurationPtr>
80  getRunConfsFromFile(const QString& filePath);
81 
82  static std::map<QString, RunConfigurationPtr>
83  readRunConfs(const NodeId& runConfNode);
84 
87  static QByteArray absoluteFileId(const QString& id, const QString& fullPath);
88 
89  void parseConf(const QVariant& json);
90  void initComponentPaths(const QVariant &v);
91 
92  QString m_confFileLocation;
93  QStringList m_componentPaths;
94  QString m_controlHostUrl;
95  QString m_runConfLocation;
96  QString m_runConfigurationName;
97  QString m_scheduleName;
98 
99  std::unique_ptr<QSettings> m_cachedSettings;
100  };
101  typedef std::shared_ptr<Configuration> ConfigurationPtr;
102 
103 }