Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxToolConfigurationParser.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXTOOLCONFIGURATIONPARSER_H_
13 #define CXTOOLCONFIGURATIONPARSER_H_
14 
15 #include "cxResourceExport.h"
16 
17 #include <utility>
18 #include <map>
19 #include <vector>
20 #include <QString>
21 #include <QDomDocument>
22 #include "cxDefinitions.h"
23 #include "cxToolFileParser.h"
24 
25 namespace cx
26 {
27 
34 class cxResource_EXPORT ConfigurationFileParser
35 {
36 public:
37 
38  struct cxResource_EXPORT ToolStructure
39  {
43  bool mReference;
46  mAbsoluteToolFilePath(""),
47  mOpenIGTLinkTransformId(""),
48  mOpenIGTLinkImageId(""),
49  mReference(false),
50  mApplyRefToTool(false)
51  {}
52  };
53 
54 
55  typedef std::vector<ToolStructure> ToolStructureVector;
56  typedef std::map<TRACKING_SYSTEM, ToolStructureVector> TrackersAndToolsMap;
58  {
59  QString mFileName;
60  QString mClinical_app;
61  QString mTrackingSystemImplementation;//Tracking system implementation (igstk or openigtlink)
62  TrackersAndToolsMap mTrackersAndTools;
64  };
65 
66 public:
67  ConfigurationFileParser(QString absoluteConfigFilePath, QString loggingFolder = "");
69 
70  QString getApplicationapplication();
71  std::vector<ToolFileParser::TrackerInternalStructure> getTrackers();
72  std::vector<QString> getAbsoluteToolFilePaths();
73  QString getAbsoluteReferenceFilePath();
74  std::vector<ConfigurationFileParser::ToolStructure> getToolListWithMetaInformation();
75 
76  static QString getTemplatesAbsoluteFilePath();
77  static void saveConfiguration(Configuration& config);
78 
79  QString getTrackingSystemImplementation();
80  bool getApplyRefToTools();
81 private:
82  void setConfigDocument(QString configAbsoluteFilePath);
83  bool isConfigFileValid();
84  QString getAbsoluteToolFilePath(QDomElement toolfileelement);
85  QString findXmlFileWithDirNameInPath(QString path);
86  QString searchForExistingToolFilePath(QString relativeToolFilePath);
87  static QString convertToRelativeToolFilePath(QString configFilename, QString absoluteToolFilePath);
88  static QString getToolPathFromRoot(QString root);
89  static void createToolFileNode(ToolStructureVector::iterator iter, QDomElement &toolFileNode, ToolFileParser &toolparser);
90 
91  QString mConfigurationFilePath;
92  QString mLoggingFolder;
93 
94  QDomDocument mConfigureDoc;
95 };
96 
97 
101 } //namespace cx
102 #endif /* CXTOOLCONFIGURATIONPARSER_H_ */
TrackersAndToolsMap mTrackersAndTools
the trackers and tools (relative path) that should be used in the config
std::map< TRACKING_SYSTEM, ToolStructureVector > TrackersAndToolsMap
QString mFileName
absolute path and filename for the new config file
std::vector< ToolStructure > ToolStructureVector
Class for reading the files defining a CustusX tool.
QString mClinical_app
the clinical application this config is made for
Class for reading the files defining a CustusX tool.
Namespace for all CustusX production code.