//
// LDASTools frameCPP - A library implementing the LIGO/Virgo frame
// specification
//
// Copyright (C) 2019 California Institute of Technology
//
// LDASTools frameCPP is free software; you may redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 (GPLv2) of the
// License or at your discretion, any later version.
//
// LDASTools frameCPP is distributed in the hope that it will be useful, but
// without any warranty or even the implied warranty of merchantability
// or fitness for a particular purpose. See the GNU General Public
// License (GPLv2) for more details.
//
// Neither the names of the California Institute of Technology (Caltech),
// The Massachusetts Institute of Technology (M.I.T), The Laser
// Interferometer Gravitational-Wave Observatory (LIGO), nor the names
// of its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// You should have received a copy of the licensing terms for this
// software included in the file LICENSE located in the top-level
// directory of this package. If you did not, you can view a copy at
// http://dcc.ligo.org/M1500244/LICENSE
//

#ifndef FrameCPP_UNIVERSAL__IMPL__FrSimEventData_HH
#define FrameCPP_UNIVERSAL__IMPL__FrSimEventData_HH

#if defined( __cplusplus )
#if !defined( SWIG )
#include <string>

#include "ldastoolsal/types.hh"

#include "framecpp/Universal/FrTable.hh"
#include "framecpp/Universal/FrVect.hh"

#include "framecpp/Universal/impl/FrObjectMetaData.hh"

#include "framecpp/Universal/impl/GPSTime.hh"

#endif /* ! defined(SWIG) */
#endif /* defined(__cplusplus) */

#undef FR_SIM_EVENT_AMPLITUDE_TYPE
#define FR_SIM_EVENT_AMPLITUDE_TYPE REAL_4

#undef FR_SIM_EVENT_PARAM_VALUE_TYPE
#define FR_SIM_EVENT_PARAM_VALUE_TYPE REAL_8

#undef FR_SIM_EVENT_N_PARAM_TYPE
#define FR_SIM_EVENT_N_PARAM_TYPE INT_2U

#undef FR_SIM_EVENT_PARAM_NAME_TYPE
#define FR_SIM_EVENT_PARAM_NAME_TYPE std::string

#undef FR_SIM_EVENT_TIME_BEFORE_TYPE
#define FR_SIM_EVENT_TIME_BEFORE_TYPE REAL_4

#undef FR_SIM_EVENT_TIME_AFTER_TYPE
#define FR_SIM_EVENT_TIME_AFTER_TYPE REAL_4

#if defined( __cplusplus )

namespace FrameCPP
{
    namespace Universal
    {
        namespace FrSimEventImpl
        {
            class Data : public Impl::FrObjectMetaData< Data >
            {
            public:
                struct v4
                {
                    using name_type = std::string;
                    using comment_type = std::string;
                    using inputs_type = std::string;
                    using GTime_type = LDASTools::AL::GPSTime;
                    using GTimeS_type = INT_4U;
                    using GTimeN_type = INT_4U;
                    using timeBefore_type = REAL_4;
                    using timeAfter_type = REAL_4;
                    using amplitude_type = REAL_4;

                    using data_type =
                        Common::SearchContainer< FrVect, &FrVect::GetName >;
                    using table_type =
                        Common::SearchContainer< FrTable,
                                                 &FrTable::GetNameSlow >;
                };
                struct v5
                {
                    using name_type = v4::name_type;
                    using comment_type = v4::comment_type;
                    using inputs_type = v4::inputs_type;
                    using GTime_type = v4::GTime_type;
                    using GTimeS_type = v4::GTimeS_type;
                    using GTimeN_type = v4::GTimeN_type;
                    using timeBefore_type = v4::timeBefore_type;
                    using timeAfter_type = v4::timeAfter_type;
                    using amplitude_type = v4::amplitude_type;
                    //-------------------------------------------------------
                    using nParam_type = INT_2U;
                    using paramName_type = std::string;
                    using paramValue_type = REAL_4;
                    using Param_type =
                        std::pair< paramName_type, paramValue_type >;
                    using ParamList_type = std::vector< Param_type >;
                    //-------------------------------------------------------
                    using data_type = v4::data_type;
                    using table_type = v4::table_type;
                };
                using v6 = v5;
                struct v7
                {
                    using name_type = v6::name_type;
                    using comment_type = v6::comment_type;
                    using inputs_type = v6::inputs_type;
                    using GTime_type = v6::GTime_type;
                    using GTimeS_type = v6::GTimeS_type;
                    using GTimeN_type = v6::GTimeN_type;
                    using timeBefore_type = v6::timeBefore_type;
                    using timeAfter_type = v6::timeAfter_type;
                    using amplitude_type = v6::amplitude_type;
                    //-------------------------------------------------------
                    using nParam_type = v6::nParam_type;
                    using paramName_type = v6::paramName_type;
                    ;
                    using paramValue_type = REAL_8;
                    using Param_type =
                        std::pair< paramName_type, paramValue_type >;
                    using ParamList_type = std::vector< Param_type >;
                    //-------------------------------------------------------
                    using data_type = v6::data_type;
                    using table_type = v6::table_type;
                };
                using v8 = v7;
                using v9 = v8;

                using current_version = v9;

                using name_type = current_version::name_type;
                using comment_type = current_version::comment_type;
                using inputs_type = current_version::inputs_type;
                using GTime_type = current_version::GTime_type;
                using GTimeS_type = current_version::GTimeS_type;
                using GTimeN_type = current_version::GTimeN_type;
                using timeBefore_type = current_version::timeBefore_type;
                using timeAfter_type = current_version::timeAfter_type;
                using amplitude_type = current_version::amplitude_type;
                //-------------------------------------------------------
                using nParam_type = current_version::nParam_type;
                using paramName_type = current_version::paramName_type;
                using paramValue_type = current_version::paramValue_type;
                using Param_type = current_version::Param_type;
                using ParamList_type = current_version::ParamList_type;
                //-------------------------------------------------------
                using data_type = current_version::data_type;
                using table_type = current_version::table_type;

                inline void
                AppendComment( const comment_type& Comment )
                {
                    FrameCPP::Common::AppendComment( comment, Comment );
                }

                inline name_type const&
                GetName( ) const
                {
                    return name;
                }

                inline comment_type const&
                GetComment( ) const
                {
                    return comment;
                }

                inline inputs_type const&
                GetInputs( ) const
                {
                    return inputs;
                }

                inline GTime_type const&
                GetGTime( ) const
                {
                    return GTime;
                }

                inline timeBefore_type
                GetTimeBefore( ) const
                {
                    return timeBefore;
                }

                inline timeAfter_type
                GetTimeAfter( ) const
                {
                    return timeAfter;
                }

                inline amplitude_type
                GetAmplitude( ) const
                {
                    return amplitude;
                }

                inline ParamList_type const&
                GetParam( ) const
                {
                    return ( Params );
                }

                inline ParamList_type&
                GetParam( )
                {
                    return ( Params );
                }

                inline const data_type&
                RefData( ) const
                {
                    return ( data );
                }

                inline data_type&
                RefData( )
                {
                    return ( data );
                }

                inline const table_type&
                RefTable( ) const
                {
                    return ( table );
                }

                inline table_type&
                RefTable( )
                {
                    return ( table );
                }

                inline static constexpr unsigned int
                GetMaxRef( )
                {
                    return ( MAX_REF );
                }

                inline bool
                operator==( Data const& RHS ) const
                {
                    return ( ( this == &RHS ) ||
                             ( ( name.compare( RHS.name ) == 0 ) &&
                               ( comment.compare( RHS.comment ) == 0 ) &&
                               ( inputs.compare( RHS.inputs ) == 0 )
                               //
                               ) );
                }

            protected:
                //-------------------------------------------------------
                /// Name of event
                //-------------------------------------------------------
                name_type name;
                //-------------------------------------------------------
                /// Descriptor of event.
                //-------------------------------------------------------
                comment_type comment;
                //-------------------------------------------------------
                /// Input channels and filter parameters to event process.
                //-------------------------------------------------------
                inputs_type inputs;
                //-------------------------------------------------------
                /// GPS time corresponding to reference value of event,
                /// as defined by the search algorithm.
                //-------------------------------------------------------
                GTime_type GTime;
                //-------------------------------------------------------
                /// Signal duration before (GTimeS.GTimeN)(seconds)
                //-------------------------------------------------------
                timeBefore_type timeBefore;
                //-------------------------------------------------------
                /// Signal duration after (GTimeS.GTimeN)(seconds)
                //-------------------------------------------------------
                timeAfter_type timeAfter;
                //-------------------------------------------------------
                /// Continuous output amplitude returned by event
                //-------------------------------------------------------
                amplitude_type amplitude;
                //-------------------------------------------------------
                /// Array of parameters
                //-------------------------------------------------------
                ParamList_type Params;
                //=======================================================
                //-------------------------------------------------------
                static constexpr unsigned int MAX_REF{ 2 };
                //-------------------------------------------------------
                /// Container of additional event results.
                //-------------------------------------------------------
                data_type data;
                //-------------------------------------------------------
                /// Table containing additional event information
                //-------------------------------------------------------
                table_type table;
            };

        } // namespace FrSimEventImpl
    } // namespace Universal
} // namespace FrameCPP

#if !defined( SWIG )
FR_OBJECT_META_DATA_DECLARE_UNIVERSAL( FrSimEventImpl )
#endif /* !defined( SWIG ) */

#endif /* defined( __cplusplus ) */

#endif /* FrameCPP_UNIVERSAL__IMPL__FrSimEventData_HH */
