DataMiningValidInterval.hh 2.36 KB
/*
 * DataMiningValidInterval.hh
 *
 *  Created on: 3 oct. 2013
 *      Author: guillaume
 */

#ifndef DATAMININGVALIDINTERVAL_HH_
#define DATAMININGVALIDINTERVAL_HH_

#include "DataMiningType.hh"

#include <utility>
#include <vector>
#include <memory>

#include "TimeInterval.hh"
#include "AbstractWriter.hh"


using namespace AMDA::Parameters;

namespace AMDA {
	namespace ParamOutputImpl {
		namespace DataMining {

			class ParamOutputDataMining;

			typedef boost::shared_ptr<TimeTable> TimeTableSPtr;

			class DataMiningValidInterval : public DataMiningType {

			public:
				DataMiningValidInterval(std::string pPrefixTTFileName, LogicalData pDataToMatch, ParamOutputDataMining* pParamOutputDataMining);

				/**
				 * @brief Change time interval on which to work.
				 * @note It also reset static data to begin with proper value and not with the old time interval.
				 */
				void setTimeInterval(const TimeInterval& pTimeInterval);

				/**
				 * @brief Create interval in which value corresponds to the given value in constructor parameter.
				 */
				void createInterval(ParamDataLogicalData* pParamData, ParamDataIndexInfo pParamDataIndexInfo);

				/**
				 * @brief Fill information (history, description, filename, ...).
				 */
				void fillInformation(TimeTable::TIME_FORMAT pTimeFormat, std::string pFileName, int pIndex = 0);

			protected:
				/**
				 * @brief _valCurrent read, true if current value is True (see LogicalData)
				*/
				bool _valCurrent;

				/**
				 * @brief _beginTimeInterval identify the beginning value of an interval
				 */
				double _beginTimeInterval;

				/**
				 * @brief _beginTimeInterval identify the ending value of an interval
				 */
				double _endTimeInterval;

				static log4cxx::LoggerPtr _logger;

			private:
				LogicalData _dataToMatch;

				void checkTimeIntervalBounds();

				void finalize();
			};

			struct DataMiningTrue : public DataMiningValidInterval {
				DataMiningTrue (ParamOutputDataMining* pParamOutputDataMining) :
					DataMiningValidInterval("", LogicalData::True,  pParamOutputDataMining) {
				}
			};

			struct DataMiningNoData : public DataMiningValidInterval {
				DataMiningNoData (ParamOutputDataMining* pParamOutputDataMining) :
					DataMiningValidInterval("Gaps_", LogicalData::NaN,  pParamOutputDataMining) {
				}
			};

		} // DataMining
	} // ParamOutputImpl
} // AMDA
#endif /* DATAMININGVALIDINTERVAL_HH_ */