ParamGetDDBase.hh 2.88 KB
/*
 * ParamGetDDClient.hh
 *
 *  Created on: 15 oct. 2012
 *      Author: casimir
 */

#ifndef PARAMGETDDCLIENT_HH_
#define PARAMGETDDCLIENT_HH_

#include <set>
#include <string>

#include <boost/shared_ptr.hpp>

#include "ParamGet.hh"
#include "Pusher.hh"

#include "TimeStamp.hh"

namespace AMDA {

	// Needed classes declaration
	namespace DDServerInterface {
		class VirtualInstrument;
		typedef boost::shared_ptr<VirtualInstrument>  VirtualInstrumentSPtr;
		namespace VI {
			class ParamFlow;
			typedef boost::shared_ptr<ParamFlow>  ParamFlowSPtr;
		}
	}

	namespace Parameters {

		//used class
		class ParamData;
		typedef boost::shared_ptr<ParamData> ParamDataSPtr;

		/**
		 * @class ParamGetDDBase
		 * @brief It is a DataWriter for a Parameter get from DDServer.
		 */
		class ParamGetDDBase: public AMDA::Parameters::ParamGet_CRTP<ParamGetDDBase> {
		public:
			typedef std::set<std::string> InfoRequestList;

			ParamGetDDBase(Parameter &parameter);
			ParamGetDDBase(const ParamGetDDBase &pParamGetDDBase, Parameter &parameter);
			virtual ~ParamGetDDBase();

			// Getter methods
			const std::string& getParName() const {
				return _parName;
			}
			const std::string& getViName() const {
				return _viName;
			}

			// Setter methods
			void setParName(const char* parName) {
				_parName = parName;
			}
			void setViName(const char* viName) {
				_viName = viName;
			}

			// Others methods
			/**
			 * Prepares ::fillParamData to retrieve additional Information(s).
			 */
			void createInfoRequest(const char* pParamInfo) {
				_infoRequestList.insert(pParamInfo);
			}

			/**
			 *  Write data in dataParam.
			 */
			unsigned int write();

			TimeStamp init();

			/*
			 * @overload DataWriter::getMinSampling
			 */
			virtual double getMinSampling();

			/**
			 * @override DataWriter::updateInfo update parameter info in relation to the ParamGet
			 */
			virtual void updateInfo(Parameter & parameter);

		protected:

			/**
			 * Get Info if needed see _infoList.
			 */
			void getDDInfo();

		private:

			/**
			 * @brief update time in the ParamData
			 * @details Must be call after createParamData
			 */
			void updateTimeInParamData(DD_data_t *data);

			/**
			 * Create ParamData from getDataTypeInfo.
			 */
			void createParamData();

			std::string _parName; /**< param name for current virtual instrument */
			std::string _viName; /**< virtual instrument name */
			Base::Pusher* _pusher; /**< Responsible push data into the good container. */
			InfoRequestList _infoRequestList; /**< List of additional information(s) needed. */
			DDServerInterface::VirtualInstrumentSPtr _vi; /**< Virtual Instrument. */
			DDServerInterface::VI::ParamFlowSPtr _paramFlow; /** Parameter data flow.*/
			TimeStamp _timeStamp; /**< time of xml file or 0 */
		};
		typedef boost::shared_ptr<ParamGetDDBase> ParamGetDDBaseSPtr;

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