FileWriterCDF.hh
5.68 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/**
* FileWriterCDF.hh
*
* Created on: 08 oct. 2014
* Author: AKKA
*/
#ifndef FILEWRITERCDF_HH_
#define FILEWRITERCDF_HH_
#include "FileWriter.hh"
#include "ParamMgr.hh"
#include "DataSetMgr.hh"
#include "InstrumentMgr.hh"
#include "MissionMgr.hh"
#include "cdf.h"
#include <map>
namespace AMDA {
namespace ParamOutputImpl {
namespace Download {
namespace FileWriter {
using namespace AMDA::Info;
/**
* @class FileWriterCDF
* @brief Implementation of FileWriter for CDF file format.
* @details
*/
class FileWriterCDF : public FileWriter
{
public:
/*
* structure used to store variable info
*/
typedef struct
{
long varNum;
long recNum;
long type;
long dim1Size;
long dim2Size;
} ParamCDFVar;
/*
* @brief Constructor
*/
FileWriterCDF(AMDA::Parameters::ParameterManager& pParameterManager);
/*
* @brief Destructor
*/
virtual ~FileWriterCDF(void);
/*
* @overload FileWriter::getExtension - method to get file format extension
*/
virtual std::string getExtension(void);
/*
* @overload FileWriter::createNewFile - Create a new CDF file
*/
virtual bool createNewFile(std::string filePath);
/*
* @overload FileWriter::closeFile - Close current opened CDF file
*/
virtual void closeFile(void);
/*
* @overload FileWriter::addParameter - Add an output parameter in CDF file
*/
virtual bool addParameter(ParamProperties* paramProp, AMDA::Common::ParameterIndexComponentList &indexList,
FileDataType type, bool isFirstParam, int dim1Size = 1, int dim2Size = 1);
/*
* @overload FileWriter::isInfoInSeparateFile - Function use to know if info must be write in a separate file
*/
virtual bool isInfoInSeparateFile(bool onlyOneInterval, OutputStructure outputStructure);
/*
* @overload FileWriter::writeError - Write an error message in the CDF file
*/
virtual bool writeError(std::string msg);
/*
* @overload FileWriter::writeAMDAInfo - Write an AMDA info bloc for CDF file
*/
virtual bool writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement);
/*
* @overload FileWriter::writeRequestInfo - Write a request info bloc for CDF file
*/
virtual bool writeRequestInfo(std::string structure, std::string timeFormat,
int timeResolution, std::string outputParams, std::string ttPath);
/*
* @overload FileWriter::writeParamsInfo - Write a parameter info bloc for CDF file
*/
virtual bool writeParamsInfo(ParamPropertiesList& paramPropertiesList, OutputStructure outputStructure,
std::string currentParamId = "");
/*
* @overload FileWriter::writeIntervalInfo - Write an interval info bloc for CDF file
*/
virtual bool writeIntervalInfo(std::string startTime, std::string stopTime);
/*
* @overload FileWriter::writeTimeData - Write a time data in the CDF file
*/
virtual bool writeTimeData(std::string paramId, double data, OutputFormatTime timeFormat, bool isFirstParam);
/*
* @overload FileWriter::writeFloatData - Write a float data in the CDF file
*/
virtual bool writeFloatData(std::string paramId, int varIndex, float data, bool precision);
/*
* @overload FileWriter::writeShortData - Write a short data in the CDF file
*/
virtual bool writeShortData(std::string paramId, int varIndex, short data, bool precision);
/*
* @overload FileWriter::writeIntData - Write a int data in the CDF file
*/
virtual bool writeIntData(std::string paramId, int varIndex, int data, bool precision);
/*
* @overload FileWriter::writeDoubleData - Write a double data in the CDF file
*/
virtual bool writeDoubleData(std::string paramId, int varIndex, double data, bool precision);
/*
* @overload FileWriter::writeLongDoubleData - Write a long double data in the CDF file
*/
virtual bool writeLongDoubleData(std::string paramId, int varIndex, long double data, bool precision);
/*
* @overload FileWriter::writeLogicalData - Write a logical data in the CDF file
*/
virtual bool writeLogicalData(std::string paramId, int varIndex, AMDA::Parameters::LogicalData data, bool precision);
/*
* @overload FileWriter::goToNextRecord - Prepare CDF writer to write the next record
*/
virtual bool goToNextRecord(std::string paramId);
/*
* @overload FileWriter::finalize - Finalize CDF file write.
*/
virtual bool finalize(bool isInfoFile = false);
protected:
/*
* @brief Write one data in the CDF file
*/
bool writeOneData(std::string paramId, int varIndex, void *data);
/*
* @brief Add a parameter in the CDF file
*/
bool addCDFParameter(std::string outputId, AMDA::Common::ParameterIndexComponentList &indexList,
FileDataType type, int dim1Size, int dim2Size);
/*
* @brief Create a variable in the CDF file
*/
bool createCDFVar(const char *name, FileDataType type, long varDim1Size, long varDim2Size,
ParamCDFVar& cdfVar);
/*
* @brief Add an attribute in the CDF file
*/
bool addAttribute(std::string attName, std::string attVal,
long scope, long varNum = 0);
/*
* @brief Write mission info attributes in the CDF file
*/
bool writeMissionInfo(MissionInfoSPtr missionInfo, long varNum);
/*
* @brief Write instrument info attributes in the CDF file
*/
bool writeInstrumentInfo(InstrumentInfoSPtr instrumentInfo, long varNum);
/*
* @brief Write dataset info attributes in the CDF file
*/
bool writeDatasetInfo(DataSetInfoSPtr datasetInfo, long varNum);
/*
* @brief Write parameter info attributes in the CDF file
*/
bool writeParameterInfo(ParamInfoSPtr parameterInfo, long varNum);
private:
/*
* @brief CDF identifier
*/
CDFid _cdfid;
/*
* @brief Map of CDF var info
*/
std::map<std::string,ParamCDFVar> _cdfVarMap;
};
} /* namespace FileWriter */
} /* namespace Download */
} /* namespace ParamOutputImpl */
} /* namespace AMDA */
#endif /* FILEWRITERCDF_HH_ */