SpectrumCreator.hh 7.1 KB
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   SpectrumCreator.hh
 * Author: hacene
 *
 * Created on December 31, 2020, 3:06 PM
 */

#ifndef SPECTRUMCREATOR_HH
#define SPECTRUMCREATOR_HH

#include "ParamData.hh"
#include "VisitorOfParamData.hh"
#include "Spectrum.hh"

namespace AMDA {
    namespace Parameters {

        class SpectrumCreator : public VisitorOfParamData {
        public:

            typedef enum {
                FOURIER,
            } SpectrumType;

            SpectrumCreator(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList, ParamData& paramInput,  SpectrumType type, double windowtime, std::string sampling = "center" )
            : _process(pProcess), _timeIntervalList(pTimeIntervalList), _paramData(paramInput), _type(type), _windowtime(windowtime), _sampling(sampling), _operation(NULL) {

                _paramData.accept(*this);
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataScalaireShort *)
             */
            void visit(ParamDataScalaireShort *) {
                createOperation<short>();
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *)
             */
            void visit(ParamDataScalaireFloat *) {
                createOperation<float>();
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *)
             */
            void visit(ParamDataScalaireDouble *) {
               createOperation<double>();
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *)
             */
            void visit(ParamDataScalaireLongDouble *) {
                createOperation<long double>();
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataScalaireInt *)
             */
            void visit(ParamDataScalaireInt *) {
               createOperation<int>();
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataLogicalData *)
             */
            void visit(ParamDataLogicalData *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab1DShort *)
             */
            void visit(ParamDataTab1DShort *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *)
             */
            void visit(ParamDataTab1DFloat *) {
               BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *)
             */
            void visit(ParamDataTab1DDouble *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *)
             */
            void visit(ParamDataTab1DLongDouble *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab1DInt *)
             */
            void visit(ParamDataTab1DInt *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *)
             */
            void visit(ParamDataTab1DLogicalData *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab2DShort *)
             */
            void visit(ParamDataTab2DShort *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *)
             */
            void visit(ParamDataTab2DFloat *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *)
             */
            void visit(ParamDataTab2DDouble *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *)
             */
            void visit(ParamDataTab2DLongDouble *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab2DInt *)
             */
            void visit(ParamDataTab2DInt *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *)
             */
            void visit(ParamDataTab2DLogicalData *) {
                BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("SpectrumCreator operation not supported"));
            }

            /**
             * @brief get the Tsyganenko96 parameterized operation.
             */
            Operation * getOperation() const {
                return _operation;
            }
        private:

            template <typename Type>
            void createOperation() {
                _operation = new Spectrum::SpectrumFourier<Type, double>(_process, _timeIntervalList, dynamic_cast<ParamDataSpec<Type> &> (_paramData), _windowtime, _sampling);
            }
            Process &_process;
            TimeIntervalListSPtr _timeIntervalList;
            ParamData &_paramData;
            SpectrumType _type;
            double _windowtime;
            std::string _sampling;
            Operation* _operation;
        };

    }
}


#endif /* SPECTRUMCREATOR_HH */