//---------------------------------------------------------------------------------
// <copyright file="SensorProgramSettings.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 SensorProgramSettings class, a serializable entity that holds
//   the settings for SensorProgram.
// </summary>
//
// <owner>Mike Cookson</owner>
//---------------------------------------------------------------------------------

#ifndef __EventLib_SensorProgramSettings_h__
#define __EventLib_SensorProgramSettings_h__

#include "EventSettings.h"
#include "EventTransceiver_Settings.h"
#include "LqrSMACSharedLib.h"
#include "LqrSMACStdOutLoggerSettings.h"
#include "PayloadManagerClientSettings.h"
#include <string>
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/version.hpp>

namespace LiquidRobotics {
namespace EventLib {

class SHARED_LIB_PUBLIC SensorProgramSettings
{
public:

	class Version
	{
	public:

		typedef std::string string;

		Version();
		Version(const Version& rhs);

		Version& operator=(const Version& rhs);

		int GetMajor() const;
		void SetMajor(int newValue);

		int GetMinor() const;
		void SetMinor(int newValue);

		int GetSubMinor() const;
		void SetSubMinor(int newValue);

		string ToString() const;

	private:

		friend class boost::serialization::access;

		template<class Archive>
		void serialize(Archive & ar, const unsigned int version)
		{
			ar & BOOST_SERIALIZATION_NVP(majorVer);
			ar & BOOST_SERIALIZATION_NVP(minorVer);
			ar & BOOST_SERIALIZATION_NVP(subminorVer);
		}

		int majorVer;
		int minorVer;
		int subminorVer;
	};

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

	SensorProgramSettings();
	SensorProgramSettings(const SensorProgramSettings& rhs);

	const string& GetServerName() const;
	void SetServerName(const string& newValue);

	const string& GetServerKind() const;
	void SetServerKind(const string& newValue);

	const Version& GetSoftwareVersion() const;
	void SetSoftwareVersion(const Version& newValue);

	const StdOutLoggerSettings& GetLoggerSettings() const;
	void SetLoggerSettings(const StdOutLoggerSettings& newValue);

	const EventSettings& GetCommandCompleteEvent() const;
	void SetCommandCompleteEvent(const EventSettings& newValue);

	const EventSettings& GetGPSEvent() const;
	void SetGPSEvent(const EventSettings& newValue);

	const EventSettings& GetShutdownEvent() const;
	void SetShutdownEvent(const EventSettings& newValue);

	const EventTransceiverSettings& GetEventTransceiverSettings() const;
	void SetEventTransceiverSettings(const EventTransceiverSettings& newValue);

	const PayloadManagerClientSettings& GetPayloadManagerClientSettings() const;
	void SetPayloadManagerClientSettings(const PayloadManagerClientSettings& 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 serialize(Archive & ar, const unsigned int version)
	{
		ar & BOOST_SERIALIZATION_NVP(serverName);
		ar & BOOST_SERIALIZATION_NVP(serverKind);
		ar & BOOST_SERIALIZATION_NVP(softwareVersion);
		ar & BOOST_SERIALIZATION_NVP(loggerSettings);
		ar & BOOST_SERIALIZATION_NVP(commandCompleteEvent);
		ar & BOOST_SERIALIZATION_NVP(gpsEvent);
		ar & BOOST_SERIALIZATION_NVP(shutdownEvent);
		ar & BOOST_SERIALIZATION_NVP(eventTransceiverSettings);
		ar & BOOST_SERIALIZATION_NVP(payloadManagerClientSettings);
	}

	string serverName;
	string serverKind;
	Version softwareVersion;
	StdOutLoggerSettings loggerSettings;
	EventSettings commandCompleteEvent;
	EventSettings gpsEvent;
	EventSettings shutdownEvent;
	EventTransceiverSettings eventTransceiverSettings;
	PayloadManagerClientSettings payloadManagerClientSettings;
};

}
}

BOOST_CLASS_VERSION(LiquidRobotics::EventLib::SensorProgramSettings, 1)
BOOST_CLASS_VERSION(LiquidRobotics::EventLib::SensorProgramSettings::Version, 1)


#endif
