Blame view

src/TimeTableCatalog/VOTableReader.hh 2.84 KB
fbe3c2bb   Benjamin Renard   First commit
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
/*
 * VOTableReader.hh
 *
 *  Created on: 7 août 2013
 *      Author: CS
 */

#ifndef VOTABLEREADER_HH_
#define VOTABLEREADER_HH_

#include "XMLReader.hh"

namespace TimeTableCatalog {

/**
 * Reads a TimeTable from an InternalXML formated file.
 * Something like :
 *  <?xml version="1.0" encoding="UTF-8"?>
 *  <VOTABLE version="1.3">
 *   <DESCRIPTION> Time Table generated by AMDA @ CDPP;
 Conditions:   Solar Proton Events Affecting the Earth Environment from http://www.swpc.noaa.gov/ftpdir/indices/SPE.txt
 January 1976 - July 2007
 PARTICLE EVENT
 Start - Maximum;
 Source: Upload Time Table;
 Creation Date :  2009-04-07 12:26:52;
 </DESCRIPTION>
 <RESOURCE>
 <DESCRIPTION> AMDA @ CDPP</DESCRIPTION>
 <TABLE>
 <FIELD datatype="char" name="Start Time" ID="TimeIntervalStart" ucd="time.start">
 <DESCRIPTION>time tag for beginning of interval</DESCRIPTION>
 </FIELD>
 <FIELD datatype="char" name="Stop Time" ID="TimeIntervalStop" ucd="time.stop">
 <DESCRIPTION>time tag for end of interval</DESCRIPTION>
 </FIELD>
 <DATA>
 <TABLEDATA>
 <TR>
 <TD>1976-04-30T21:20:00</TD>
 <TD>1976-05-01T17:00:00</TD>
 </TR>
 <TR>
 <TD>1977-09-19T14:30:00</TD>
 <TD>1977-09-19T21:30:00</TD>
 </TR>
 </TABLEDATA>
 </DATA>
 </TABLE>
 </RESOURCE>
 </VOTABLE>
 *
 */
class VOTableReader: public TimeTableCatalog::XMLReader {
public:

	static const std::string FORMAT;

	VOTableReader(const std::string& pPath);
	virtual ~VOTableReader();

	/**
	 * Creates an instance of this.
	 */
	std::unique_ptr<AbstractReader> createInstance(const std::string& pPath);

	/**
	 * Gets the first xml node of the tt in this XML format.
	 */
	std::string getFirstNode();

68c29629   Benjamin Renard   Fix in TT/Catalog...
72
73
	ParameterDescription::ParameterType getTypeFromString(std::string type);

fbe3c2bb   Benjamin Renard   First commit
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
private:

	/**
	 * Processes each interested node of an XMl file.
	 */
	void processNode(TimeTable& pTT, xmlTextReaderPtr reader, int &crtIndex);

	/**
	 * Read DESCRIPTION tags
	 */
	void readDescription(TimeTable& pTT, xmlTextReaderPtr reader);

	/**
	 * Read FIELD tags
	 */
	void readField(TimeTable& pTT, xmlTextReaderPtr reader);

	/**
	 * Read TR/TD tags
	 */
	void readInterval (TimeTable& pTT, xmlTextReaderPtr reader, int pcrtIndex);

	/**
	 * Extracts metadata from a tag text.
	 */
	void readMetadata(const std::string& pDescription, TimeTable& pTimeTable);

68c29629   Benjamin Renard   Fix in TT/Catalog...
101
	bool _readingVOTable;
fbe3c2bb   Benjamin Renard   First commit
102

68c29629   Benjamin Renard   Fix in TT/Catalog...
103
104
105
	bool _readingResource;

	bool _readingTable;
fbe3c2bb   Benjamin Renard   First commit
106
107

	/**
68c29629   Benjamin Renard   Fix in TT/Catalog...
108
	 * Flag indicating we are currently reading a FIELD TAG
fbe3c2bb   Benjamin Renard   First commit
109
	 */
68c29629   Benjamin Renard   Fix in TT/Catalog...
110
	bool    _readingField;
fbe3c2bb   Benjamin Renard   First commit
111
112

	/**
68c29629   Benjamin Renard   Fix in TT/Catalog...
113
	 *  Flag indicating we are currently reading a DESCRITPTION TAG
fbe3c2bb   Benjamin Renard   First commit
114
	 */
68c29629   Benjamin Renard   Fix in TT/Catalog...
115
	bool    _readingDescription;
fbe3c2bb   Benjamin Renard   First commit
116
117
118
119

	/**
	 * Flag indicating we are currently reading a TR TAG
	 */
68c29629   Benjamin Renard   Fix in TT/Catalog...
120
	bool    _readingTr;
fbe3c2bb   Benjamin Renard   First commit
121
122
123
124

	/**
	 * Flag indicating we are currently reading a TD TAG
	 */
68c29629   Benjamin Renard   Fix in TT/Catalog...
125
	bool    _readingTd;
fbe3c2bb   Benjamin Renard   First commit
126
127
128
129

	/**
	 * Current TD TAG count
	 */
68c29629   Benjamin Renard   Fix in TT/Catalog...
130
131
132
133
134
135
	int _tdCount;

	/**
	 * Current FIELD TAG count
	 */
	int _fieldCount;
fbe3c2bb   Benjamin Renard   First commit
136
137
138
139
};

} /* namespace TimeTableCatalog */
#endif /* VOTABLEREADER_HH_ */