FileWriterCDF.h 1.58 KB
#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