Blame view

src/TimeTableCatalog/SpaceWriter.hh 1.68 KB
04d31e39   Hacene SI HADJ MOHAND   new format ok
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
/*
 * SpaceWriter.hh
 *
 *  Created on: 31/05/2021
 *  AKKA
 */

#ifndef SPACEWRITER_HH_
#define SPACEWRITER_HH_

#include "AbstractWriter.hh"
#include <iostream>

namespace TimeTableCatalog {

/**
 * Writes a TimeTable into an SPACE formated file.
 * Something like :
 * #Time Table generated by AMDA @ CDPP;
 * #Name: testTable_M_lll;
 * #Description: ;
 * #Historic: Union between testTable lll ;
 * #Creation Date :  2012-09-05T19:15:47;
 * #
 * 2001-02-07T18:39:11 2001-02-07T18:59:11
 * 2001-02-07T19:49:11 2001-02-07T19:59:11
 * 2001-02-08T02:29:11 2001-02-08T03:04:11
 */
class SpaceWriter: public AbstractWriter {
public:
	SpaceWriter(const std::string& pPath, const std::string& pName = "");
	virtual ~SpaceWriter();

	static const std::string FORMAT;

	/**
	 * Writes a TimeTable into an SPACE 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 all metadata as name, description etc. into an SPACE formated file.
	 */
	void writeMetaData(const TimeTable& pTT, std::ostream& pout);

	/**
	 * Writes all TT intervals into an SPACE formated file.
	 */
	void writeIntervals(const TimeTable& pTT, std::ostream& pout);
};

/**
 * Splits a string around a given delimiter.
 */
std::vector<std::string> &split(const std::string &s, char delim,
		std::vector<std::string> &elems);

} /* namespace TimeTableCatalog */
#endif /* SPACEWRITER_HH_ */