InternalXMLWriter.hh 2.64 KB
/*
 * InternalXMLWriter.hh
 *
 *  Created on: 6 août 2013
 *      Author: CS
 */

#ifndef INTERNALXMLWRITER_HH_
#define INTERNALXMLWRITER_HH_

#include "XMLWriter.hh"
#include <string>

namespace TimeTableCatalog {

/**
 * Writes TimeTable into an InternalXML formated file.
 * Something like :
 *  <?xml version="1.0" encoding="UTF-8"?>
 *  <timetable>
 *    <name>FTE_c3</name>
 *    <created>2013-07-14T09:09:32</created>
 *    <description>Uploaded Time Table
 *    Time Table generated by AMDA @ CDPP;Description: FTE list from Cluster 3 data. From \"A new multivariate time series data analysis technique: Automated detection of flux transfer events using Cluster data\" by Karimabadi et al., JOURNAL OF GEOPHYSICAL RESEARCH, VOL. 114, A06216, doi:10.1029/2009JA014202, 2009 http://www.agu.org/journals/ja/ja0906/2009JA014202/The list is available as Auxiliary material \"Data Set S3\"Transformation into AMDA Time Table by V. Genot, CESR, Toulouse, France 29/06/2009 : - millisec have been omitted - the original event corresponds to the StartTime of the Time Table - if StopTime-StartTime = 1 sec then the event is a magnetosheath FTE - if StopTime-StartTime = 2 sec then the event is a magnetospheric FTE;Source: Upload Time Table;Creation Date :  2009-07-01 17:16:46 shared by Vincent Genot on 2009-11-24 18:52:50;</description>
 *    <history>created from another TT</history>
 *    <nbIntervals>738</nbIntervals>
 *    <intervals>
 *      <start>2001-02-02T16:27:12</start>
 *      <stop>2001-02-02T16:27:13</stop>
 *    </intervals>
 *    <!--[...]-->
 *  </timetable>
 *
 */
class InternalXMLWriter: public TimeTableCatalog::XMLWriter {
public:

	static const std::string FORMAT;

	InternalXMLWriter(const std::string& pPath, const std::string& pName = "");
	virtual ~InternalXMLWriter();

	/**
	 * Writes TimeTable into an InternalXML formated file.
	 */
	std::string write(const TimeTable& pTT);

	/**
	 * Creates an instance of this.
	 */
	std::unique_ptr<AbstractWriter> createInstance(const std::string& pPath, const std::string& pName = "");

	/**
	 * Gets the tt file expected extension, starting with .
	 */
	const std::string getExtension() const;

	std::string getTypeAsString(ParameterDescription::ParameterType type);

private:

	/**
	 * Writes XML content (except header).
	 */
	void writeContent(const TimeTable& pTT, xmlTextWriterPtr& pWriter);

	/**
	 * Writes all metadata tags as name, description, nbintervals etc.
	 */
	void writeMetadata(const TimeTable& pTT, xmlTextWriterPtr& pWriter);

	/**
	 * Writes all intervals.
	 */
	void writeIntervals(const TimeTable& pTT, xmlTextWriterPtr& pWriter);

};

} /* namespace TimeTableCatalog */
#endif /* INTERNALXMLWRITER_HH_ */