//------------------------------------------------------------------------------
// <copyright file="SSQProgramSettings.h" company="LiquidRobotics">
//
// Copyright (c) 2014 Liquid Robotics, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// This software is associated with a release.  Liquid Robotics makes no
// representation that the design, interfaces or component distribution will
// remain unchanged in future releases.
//
// </copyright>
//
// <summary>
// 	Declarations for SSQProgramSettings, a serialiable entity that holds the
//  settings for the SSQ sensor Program class.
// </summary>
//
// <owner>Mike Cookson</owner>
//------------------------------------------------------------------------------

#ifndef __SSQProgramSettings_h__
#define __SSQProgramSettings_h__

#include "LqrSMACSharedLib.h"
#include "SSQControllerSettings.h"
#include "SensorProgramSettings.h"
#include <string>
#include <boost/serialization/access.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/version.hpp>

namespace LiquidRobotics {
namespace SimpleSBDQueue {

class SHARED_LIB_PUBLIC SSQProgramSettings
{
public:

	typedef LiquidRobotics::EventLib::EventSettings EventSettings;
	typedef LiquidRobotics::EventLib::EventTransceiverSettings EventTransceiverSettings;
	typedef LiquidRobotics::EventLib::SensorProgramSettings SensorProgramSettings;
	typedef LiquidRobotics::SMACFramework::StdOutLoggerSettings StdOutLoggerSettings;
	typedef LiquidRobotics::EventLib::PayloadManagerClientSettings PayloadManagerClientSettings;
	typedef std::string string;

	SSQProgramSettings();
	SSQProgramSettings(const SSQProgramSettings& rhs);

	SSQProgramSettings& operator=(const SSQProgramSettings& rhs);

    const EventSettings& GetReceivedPacketEvent() const;
    void SetReceivedPacketEvent(const EventSettings& newValue);

    const EventSettings& GetEnqueuePacketEvent() const;
    void SetEnqueuePacketEvent(const EventSettings& newValue);

    const EventSettings& GetTransmitDispositionEvent() const;
    void SetGetTransmitDispositionEvent(const EventSettings& newValue);

    const EventSettings& GetChannelStatsEvent() const;
    void SetChannelStatsEvent(const EventSettings& newValue);

	const SSQControllerSettings& GetControllerSettings() const;
	void SetControllerSettings(SSQControllerSettings& newValue);

	const SensorProgramSettings& GetSensorProgramSettings() const;
	void SetSensorProgramSettings(const SensorProgramSettings& newValue);

	void Load(const string& fileName, bool withMD5 = false);
	void Save(const string& fileName, bool withMD5 = false) const;

private:

	friend class boost::serialization::access;

	template<class Archive>
	void load(Archive & ar, const unsigned int version)
	{
        ar >> BOOST_SERIALIZATION_NVP(receivedPacketEvent);             // 1
        ar >> BOOST_SERIALIZATION_NVP(enqueuePacketEvent);              // 1
        ar >> BOOST_SERIALIZATION_NVP(transmitDispositionEvent);		// 1
        ar >> BOOST_SERIALIZATION_NVP(channelStatsEvent);               // 1
		ar >> BOOST_SERIALIZATION_NVP(sensorProgramSettings);			// 1
		ar >> BOOST_SERIALIZATION_NVP(controllerSettings);				// 1
	}

	template<class Archive>
	void save(Archive & ar, const unsigned int version) const
	{
        ar << BOOST_SERIALIZATION_NVP(receivedPacketEvent);             // 1
        ar << BOOST_SERIALIZATION_NVP(enqueuePacketEvent);              // 1
        ar << BOOST_SERIALIZATION_NVP(transmitDispositionEvent);		// 1
        ar << BOOST_SERIALIZATION_NVP(channelStatsEvent);               // 1
		ar << BOOST_SERIALIZATION_NVP(sensorProgramSettings);			// 1
		ar << BOOST_SERIALIZATION_NVP(controllerSettings);				// 1
	}

	BOOST_SERIALIZATION_SPLIT_MEMBER()

    EventSettings receivedPacketEvent;
    EventSettings enqueuePacketEvent;
    EventSettings transmitDispositionEvent;
    EventSettings channelStatsEvent;

	SensorProgramSettings sensorProgramSettings;
	SSQControllerSettings controllerSettings;
};

}
}

BOOST_CLASS_VERSION(LiquidRobotics::SimpleSBDQueue::SSQProgramSettings, 1)

#endif
