ParamGetDDBase.hh 4.38 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;
			}
			int getMaxDim1Size() {
				return _maxDim1Size;
			}
			int getMaxDim2Size() {
				return _maxDim2Size;
			}
			int getMaxDim3Size() {
				return _maxDim3Size;
			}
			int getDim3Num() {
				return _dim3Num;
			}
			int getDim3CutIndex() {
				return _dim3CutIndex;
			}
                                                            int getMinSumIndex(){
                                                                                return _minSumIndex;
                                                            }
                                                            int getMaxSumIndex(){
                                                                                return _maxSumIndex;
                                                            }

			// Setter methods
			void setParName(const char* parName) {
				_parName = parName;
			}
			void setViName(const char* viName) {
				_viName = viName;
			}
			void setMaxDim1Size(const int maxDim1Size) {
				_maxDim1Size = maxDim1Size;
			}
			void setMaxDim2Size(const int maxDim2Size) {
				_maxDim2Size = maxDim2Size;
			}
			void setMaxDim3Size(const int maxDim3Size) {
				_maxDim3Size = maxDim3Size;
			}
			void setDim3Num(const int dim3Num) {
				_dim3Num = dim3Num;
			}
			void setDim3CutIndex(const int dim3CutIndex) {
				_dim3CutIndex = dim3CutIndex;
			}
                        		void setMinSumIndex(const int minSumIndex) {
				_minSumIndex = minSumIndex;
			}
                                                            void setMaxSumIndex(const int maxSumIndex) {
				_maxSumIndex = maxSumIndex;
			}

			// 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:

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

			std::string _parName; /**< param name for current virtual instrument */
			std::string _viName; /**< virtual instrument name */
			int _maxDim1Size;
			int _maxDim2Size;
			int _maxDim3Size;
			int _dim3Num;
			int _dim3CutIndex;
                                                            int _minSumIndex;
                                                            int _maxSumIndex;
			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_ */