//-------------------------------------------------------------------------------------------------
// <copyright file="SEProgramSettings.h" company="LiquidRobotics">
//  Copyright (c) Liquid Robotics Corporation, confidential and proprietary.  All rights reserved. 
// </copyright>
//
// <summary>
// 	Declarations for SEProgramSettings, a serialiable entity that holds the
//  settings for an example sensor Program class.
// </summary>
//
// <owner>Mike Cookson</owner>
//-------------------------------------------------------------------------------------------------

#ifndef __SEProgramSettings_h__
#define __SEProgramSettings_h__

#include "LqrSMACSharedLib.h"
#include "SEControllerSettings.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 SensorExample {

class SHARED_LIB_PUBLIC SEProgramSettings
{
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;

	SEProgramSettings();
	SEProgramSettings(const SEProgramSettings& rhs);

	SEProgramSettings& operator=(const SEProgramSettings& rhs);

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

	const EventSettings& GetTagEventSettings() const;
	void SetTagEventSettings(const EventSettings& 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(sensorProgramSettings);			// 1
		ar >> BOOST_SERIALIZATION_NVP(controllerSettings);				// 1

		if (version >= 2)
			ar >> BOOST_SERIALIZATION_NVP(tagEventSettings);			// 2
	}

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

	BOOST_SERIALIZATION_SPLIT_MEMBER()

	SensorProgramSettings sensorProgramSettings;
	SEControllerSettings controllerSettings;
	EventSettings tagEventSettings;
};

}
}

BOOST_CLASS_VERSION(LiquidRobotics::SensorExample::SEProgramSettings, 2)

#endif
