//
// 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__FrMsgData_HH
#define FrameCPP__UNIVERSAL__IMPL__FrMsgData_HH

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

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

namespace FrameCPP
{
    namespace Universal
    {
        namespace FrMsgImpl
        {
            class Data : public Impl::FrObjectMetaData< Data >
            {
            public:
                struct v3
                {
                    using alarm_type = std::string;
                    using message_type = std::string;
                    using severity_type = INT_4U;
                };

                using v4 = v3;

                struct v5
                {
                    using alarm_type = typename v4::alarm_type;
                    using message_type = typename v4::message_type;
                    using severity_type = typename v4::severity_type;
                    using GTimeS_type = INT_4U;
                    using GTimeN_type = INT_4U;
                    using GTime_type = GPSTime;
                };

                using v6 = v5;
                using v7 = v6;
                using v8 = v7;
                using v9 = v8;

                //-------------------------------------------------------

                using current_version = v9;

                using alarm_type = typename current_version::alarm_type;
                using GTime_type = typename current_version::GTime_type;
                using GTimeN_type = typename current_version::GTimeN_type;
                using GTimeS_type = typename current_version::GTimeS_type;
                using message_type = typename current_version::message_type;
                using severity_type = typename current_version::severity_type;

                inline const alarm_type&
                GetAlarm( ) const
                {
                    return ( alarm );
                }

                inline const message_type&
                GetMessage( ) const
                {
                    return ( message );
                }

                inline severity_type
                GetSeverity( ) const
                {
                    return ( severity );
                }

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

                inline void
                SetAlarm( const alarm_type& Value )
                {
                    alarm = Value;
                }

                inline void
                SetMessage( const message_type& Value )
                {
                    message = Value;
                }

                inline void
                SetSeverity( severity_type Value )
                {
                    severity = Value;
                }

                inline void
                SetGTime( GTime_type Value )
                {
                    GTime = Value;
                }

                bool
                operator==( const Data& RHS ) const
                {
                    return ( ( alarm == RHS.alarm ) && //
                             ( message == RHS.message ) && //
                             ( severity == RHS.severity ) && //
                             ( GTime == RHS.GTime ) );
                }

            protected:
                //-------------------------------------------------------------
                /// Name of message, error flag or alarm state
                //-------------------------------------------------------------
                alarm_type alarm;
                //-------------------------------------------------------------
                /// Message body
                //-------------------------------------------------------------
                message_type message;
                //-------------------------------------------------------------
                /// Message severity level (To Be Defined)
                //-------------------------------------------------------------
                severity_type severity;
                //-------------------------------------------------------------
                /// GPS time coresponding to this FrMsg
                //-------------------------------------------------------------
                GTime_type GTime;
            };
        } // namespace FrMsgImpl
    } // namespace Universal
} // namespace FrameCPP

FR_OBJECT_META_DATA_DECLARE_UNIVERSAL( FrMsgImpl )

#endif /* FrameCPP__UNIVERSAL__IMPL__FrMsgData_HH */
