/******************************************************************************
** Copyright (c) 2015 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/

//! \file DtSceneRecord.h
//! \brief Contains makArchives::DtSceneRecord class.
//! \ingroup makArchives

#pragma once

#include <makArchives/makArchives.h>
#include <makArchives/DtTerrainRecord.h>
#include <makArchives/DtEnvironmentRecord.h>
#include <makArchives/DtDateTimeRecord.h>

namespace makArchives
{
   //! A record for describing a scene.
   //! \ingroup makArchives
   class DT_DLL_MAKARCHIVES DtSceneRecord
   {
   public:

      //! CTOR
      DtSceneRecord();

      //! CCTOR
      DtSceneRecord(const DtSceneRecord&);

      //! Assignment Op.
      DtSceneRecord& operator=(const DtSceneRecord&);

      //! DTOR
      virtual ~DtSceneRecord();

      //! Attempt to get the embedded terrain record.
      //! Will be empty for version 2 and higher
      const DtTerrainRecord& terrainRecord() const;

      //! Get the terrain filename (this will be "" if
      //! the scene record is not version 2 or higher).
      //! In that case, use terrainRecord()
      const std::string& terrainFilename() const;

      //! Sets the embedded terrain record.
      //void setTerrainRecord(const DtTerrainRecord& record);
      void setTerrainFilename( const std::string& filename );

      //! Attempt to get the embedded terrain record.
      const DtEnvironmentRecord& environmentRecord() const;

      //! Sets the embedded terrain record.
      void setEnvironmentRecord(const DtEnvironmentRecord& record);

      //! Attempt to get the embedded date and time record.
      const DtDateTimeRecord& dateTimeRecord() const;

      //! Sets the embedded date and time record.
      void setDateTimeRecord(const DtDateTimeRecord& record);
      
      //! \brief Set the scene description.
      virtual void setDescription(const std::string& description);

      //! \brief Get the scene description.
      virtual const std::string& description() const;

   protected:

      friend class boost::serialization::access;

      //! When the class Archive corresponds to an output archive, the
      //! & operator is defined similar to <<.  Likewise, when the class Archive
      //! is a type of input archive the & operator is defined similar to >>.
      template<class Archive>
      void serialize(Archive & ar, const unsigned int version)
      {
         if ( version < 2 )
         {
            ar & BOOST_SERIALIZATION_NVP(myEmbeddedTerrainRecord);
         }

         ar & BOOST_SERIALIZATION_NVP(myEmbeddedEnvironmentRecord);

         if(version >= 1)
         {
            ar & BOOST_SERIALIZATION_NVP(myEmbeddedDateTimeRecord);
         }

         if ( version >= 2 )
         {
            ar & BOOST_SERIALIZATION_NVP(myTerrainFilename);
         }

         if ( version >= 3)
         {
            ar & BOOST_SERIALIZATION_NVP(myDescription);            
         }
      }

   protected:

      mutable DtTerrainRecord myEmbeddedTerrainRecord;
      mutable DtEnvironmentRecord myEmbeddedEnvironmentRecord;
      DtDateTimeRecord myEmbeddedDateTimeRecord;
      std::string myTerrainFilename;
      std::string myDescription;
   };
}

BOOST_CLASS_VERSION(makArchives::DtSceneRecord,3)


