Blame view

src/Parameters/DataWriter.hh 3.76 KB
fbe3c2bb   Benjamin Renard   First commit
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
/**
 * DataWriter.hh
 *
 *  Created on: Nov 14, 2012
 *      Author: AKKA IS
 */

#ifndef DATAWRITER_HH_
#define DATAWRITER_HH_

#include <string>
#include <list>
#include <boost/shared_ptr.hpp>

#include <log4cxx/logger.h>

#include "TimeInterval.hh"


namespace AMDA {
namespace Parameters {

//use class
class Parameter;
class ParamData;
typedef boost::shared_ptr<ParamData> ParamDataSPtr;
class ParameterManager;
class DataWriter;
typedef boost::shared_ptr<DataWriter> DataWriterSPtr;

typedef std::list<TimeTableCatalog::TimeInterval> TimeIntervalList;
typedef boost::shared_ptr<TimeIntervalList> TimeIntervalListSPtr;

class TimeStamp ;

class DataWriter {
public:
	/**
	 * @brief default constructor
	 */
	DataWriter(Parameter &parameter);

	/**
	 * @brief constructor by copy
	 */
	DataWriter(const DataWriter &pDataWriter, Parameter &parameter);

	/**
	 * @brief destructor
	 */
	virtual ~DataWriter();

	/**
	 * @brief _paramData getter
	 */
	ParamDataSPtr& getParamData() {	return _paramData; }

	/**
	 * @brief parameterManager of _parameter getter
	 */
	ParameterManager &getParameterManager();

	/**
	 *@brief #_parameter getter
	 */
	Parameter *getParameter() {	return &_parameter;	}

	/**
	 * @brief _paramData setter
	 */
	void setParamData(const ParamDataSPtr& paramData) {	_paramData = paramData;	}

	/**
	 * @brief set _signatureTrigger
	 * @details this string which permit to compute  TimeStamp @see init()
	 * 		Classically, is the parameter.xml file name.
	 */
	void setSignatureTrigger(const std::string& pSignatureTrigger) {	_signatureTrigger = pSignatureTrigger;	}

	// Others Methods

	/**
	 * @brief initialization of get method
	 * @details Initialize time data and call DataWriter::init()
	 */
	TimeStamp  init(TimeIntervalListSPtr pTimeIntervalList);

	/**
	 *  @brief Write data in dataParam and return the number of data writed.
	 */
	virtual unsigned int write() = 0;

	/**
	 *  @brief Switch the current time interval and reset data.
	 */
//	virtual void switchTimeInterval() = 0;

	/**
	 *  @brief Write data in dataParam.
	 */
	virtual DataWriter *clone(Parameter &parameter) const = 0;

	/**
	 *  @brief Write data in dataParam.
	 */
	virtual double getMinSampling() = 0;

	/**
	 * @brief Get the resampling strategy. If it's true, the nearest value will be used during a resampling
	 */
	virtual bool useNearestValue() = 0;

	/**
	 * @brief update parameter info
	 */
	virtual void updateInfo(Parameter & parameter);

263de286   Benjamin Renard   Apply time restri...
118
119
120
121
122
123
124
125
126
127
            void setTimeRestriction(double restriction) {
                _timeRestriction = restriction;
            }

            double getTimeRestriction() {
                return _timeRestriction;
            }

	void applyTimeRestriction(unsigned int startIndex, unsigned int nbDataToProcess);

fbe3c2bb   Benjamin Renard   First commit
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
protected:

	Parameter&  _parameter;

	/**
	 * @brief initialization of get method
	 * create real ParamData
	 */
	virtual TimeStamp init() = 0;

	TimeIntervalListSPtr _timeIntervalList;

	/**
	 * @brief ParamData output
	 */
	ParamDataSPtr  _paramData;

	/**
	 * @brief string which permit to compute  TimeStamp @see init()
	 */
	std::string _signatureTrigger;

	static log4cxx::LoggerPtr _logger;
263de286   Benjamin Renard   Apply time restri...
151
152

	double _timeRestriction;
fbe3c2bb   Benjamin Renard   First commit
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
};

/**
 *  This CRTP class implements clone() for Derived
 */
template <typename Derived>
class DataWriter_CRTP : public DataWriter {
public:
	/**
	 * @brief Default constructor
	 */
	DataWriter_CRTP(Parameter &parameter) : DataWriter(parameter) {}

	/**
	 * @brief Constructor by copy
	 */
	DataWriter_CRTP(const DataWriter &pDataWriter, Parameter &parameter) : DataWriter(pDataWriter,parameter) {}

   /**
    * @overload Process::clone
    */
	virtual DataWriter *clone(Parameter &parameter) const {
        return new Derived(static_cast<Derived const&>(*this),parameter);
    }
};

} /* namespace Parameters */
} /* namespace AMDA */
#endif /* DATAWRITER_HH_ */