FileWriterCDF.h
1.58 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
#ifndef FILEWRITERCDF_H
#define FILEWRITERCDF_H
#include "cdf.h"
#include "FileWriterAbstract.h"
namespace TREPS
{
namespace File
{
class FileWriterCDFClass : public FileWriterAbstractClass
{
public :
FileWriterCDFClass(void);
~FileWriterCDFClass(void);
//create a CDF file, and add general attributes
bool init(const char *file_path, const map<string,string> *attributes);
//write fields and data
bool writeData(const DataRecordListClass *data, t_TimeFormat timeFormat,
const char *timePattern, const t_FieldList *fields);
//save file
bool save(void);
//close file
bool close(void);
//test if the file is opened
bool isOpened(void);
private:
//CDF identifier
CDFid cdfid;
//CDF buffer for status text
char cdfbuffer[CDF_STATUSTEXT_LEN+1];
//path to current initialized file
string filePath;
//add CDF attribute
bool addAttribute(const char *attName, const char *attVal, long scope, long varNum = 0);
//get CDF variable definition
bool getCDFVarTypeDef(const t_Field *field, const DataRecordListClass *data, long &cdfType, long &numElts);
//write a field to CDF file
bool writeField(const t_Field *field, const DataRecordListClass *data, long &varNum);
//write field data to CDF file
bool writeFieldData(const t_Field *field, const DataRecordListClass *data, long varNum, long cdfType, long numElts);
//convert data to CDF buffer
bool convertData(const t_Field *field, DataRecordClass *record, const char *key, long cdfType, long numElts, void *buffer);
};
}
}
#endif