//
// LDASTools frameCPP - A library implementing the LIGO/Virgo frame
// specification
//
// Copyright (C) 2018 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_FrTOCEventData_HH
#define FrameCPP_UNIVERSAL_FrTOCEventData_HH

#if !defined( SWIGIMPORTED )
#include "framecpp/Universal/impl/FrTOCEventClassicIO.hh"

#endif /* ! defined(SWIGIMPORTED) */

#if !defined( SWIGIMPORTED )

namespace FrameCPP
{
#if !defined( SWIGIMPORTED )
    namespace Common
    {
        class TOCInfo;
    }
#endif /* ! defined(SWIGIMPORTED) */

    namespace Universal
    {
        //===================================================================
        /// \brief Indexed elements of the FrSimData structure.
        //===================================================================
        class FrTOCEvent : public virtual FrTOCImpl::FrTOCEventClassicIO
        {
        public:
            //-----------------------------------------------------------------
            /// \brief Default constructor.
            //-----------------------------------------------------------------
            FrTOCEvent( ) = default;

            //-----------------------------------------------------------------
            /// \brief Gather TOC info for FrSimData being written.
            ///
            /// \param[in] Info
            ///     Information
            ///
            /// \param[in] FrameOffset
            ///     The frame offset of the frame being written.
            ///     The frame offsets start at 0 (zero).
            ///
            /// \param[in] Position
            ///     The byte offset from the start of the file
            ///     where the structure is written.
            //-----------------------------------------------------------------
            void QuerySim( const Common::TOCInfo& Info,
                           INT_4U                 FrameOffset,
                           INT_8U                 Position );

            //-----------------------------------------------------------------
            /// \brief equality operator
            ///
            /// \param[in] RHS
            ///     The FrTOCAdcData object to be compared.
            ///
            /// \return
            ///     The value true is returned if this object is equivelent
            ///     to the RHS instance; false otherwise.
            //-----------------------------------------------------------------
            bool operator==( const FrTOCEvent& RHS ) const;

            //-----------------------------------------------------------------
            /// \brief Read contents from stream
            ///
            /// \param[in] Stream
            ///     The stream from which the object is being read.
            ///
            /// \return
            ///    A new instance of this object.
            //-----------------------------------------------------------------
            void Load( istream_type& Stream, INT_4U FrameCount );

        protected:
            //-----------------------------------------------------------------
            /// \brief Iterate over contents.
            ///
            /// \param[in] Info
            ///     Specifies the type of information to be searched.
            ///
            /// \param[in] Action
            ///     Action to be taken for each piece of information found.
            //-----------------------------------------------------------------
            void forEach( Common::FrTOC::query_info_type Info,
                          Common::FrTOC::FunctionBase&   Action ) const;

            //-----------------------------------------------------------------
            /// \brief Write the structure to the stream
            ///
            /// \param[in] Stream
            ///     The output stream where the object is to be written.
            //-----------------------------------------------------------------
            void write( Common::OStream& Stream ) const;
        };

    } // namespace Universal
} // namespace FrameCPP

#endif /* ! defined(SWIGIMPORTED) */

#endif /* FrameCPP_UNIVERSAL_FrTOCEvent_HH */
