Updraft
1.0
Open source glider flight visualisation tool.
|
00001 #ifndef UPDRAFT_SRC_LIBRARIES_CUP_CUP_H_ 00002 #define UPDRAFT_SRC_LIBRARIES_CUP_CUP_H_ 00003 00004 #include <QtCore/QtGlobal> 00005 #include <QString> 00006 #include <QList> 00007 #include "../util/util.h" 00008 00009 #ifdef UPDRAFT_CUP_INTERNAL 00010 # define CUP_EXPORT Q_DECL_EXPORT 00011 #else 00012 # define CUP_EXPORT Q_DECL_IMPORT 00013 #endif 00014 00015 namespace Updraft { 00016 namespace Cup { 00017 00018 class CupLoader; 00019 00022 // TODO(Tom): Format values (e.g. remove double quotes) 00023 struct CUP_EXPORT TPEntry { 00024 QString name; 00025 QString code; 00026 QString country; 00027 Util::Location location; 00028 QString style; 00029 QString rwyDirection; 00030 QString rwLength; 00031 QString frequency; 00032 QString description; 00033 }; 00034 00036 // TODO(Tom): Think wheter to load the tasks from cup. 00037 struct CUP_EXPORT TaskEntry { 00038 }; 00039 00043 class CUP_EXPORT CupFile { 00044 public: 00045 // TODO(Tom): Define interface 00046 00048 QString getFileName() const; 00049 00051 QList<TPEntry> getTPEntries() const; 00052 00053 private: 00054 QString fileName; 00055 00056 // TODO(Tom): Consider the best container type (e.g. map) 00057 QList<TPEntry> turnPoints; 00058 QList<TaskEntry> tasks; 00059 00061 CupFile() {} 00062 00066 void setFileName(const QString &name); 00067 00071 void addTPEntry(const TPEntry &tp); 00072 00076 void addTaskEntry(const TaskEntry &task); 00077 00078 friend class CupLoader; 00079 }; 00080 00083 class CUP_EXPORT CupLoader { 00084 public: 00085 CupLoader(); 00086 00090 CupFile* loadFile(const QString &name); 00091 00092 protected: 00094 enum LoadingState { 00095 LOADING_HEADER, 00096 LOADING_TPS, 00097 LOADING_TASKS, 00098 UNDEFINED, 00099 DONE, 00100 ERROR 00101 }; 00102 00103 LoadingState state; // Inner state of the loading process 00104 CupFile *cupFile; // Instance of the currently built file 00105 00108 void parseLine(const QString &strLine); 00109 00113 void parseLatitude(TPEntry &tp, const QString &latitude); 00114 00118 void parseLongitude(TPEntry &tp, const QString &longitude); 00119 00123 void parseElevation(TPEntry &tp, const QString &elevation); 00124 00127 void parseTP(const QString &strLine); 00128 00131 void parseTask(const QString &strLine); 00132 }; 00133 00134 } // End namespace Cup 00135 } // End namespace Updraft 00136 00137 #endif // UPDRAFT_SRC_LIBRARIES_CUP_CUP_H_