//---------------------------------------------------------------------------------
// <copyright file="VirtualRelayControllerSettings.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>
// 	Declaration of VirtualRelayControllerSettings class, a serializable entity that
//  holds the various settings for the VirtualRelayController class
// </summary>
//
// <owner>Arash Ushani</owner>
//---------------------------------------------------------------------------------

#ifndef __VirtualRelayControllerSettings_H__
#define __VirtualRelayControllerSettings_H__

#include "VirtualRelayMessageManagerSettings.h"
#include <string>
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/version.hpp>

namespace LiquidRobotics {
namespace VirtualRelay {

class SHARED_LIB_PUBLIC VirtualRelayControllerSettings
{
public:

	typedef std::string string;

	VirtualRelayControllerSettings();
	VirtualRelayControllerSettings(const VirtualRelayControllerSettings& rhs);

	const string& GetHost() const;
	void SetHost(const string& newValue);

	const int GetHostPort() const;
	void SetHostPort(const int newValue);

	const int GetCommsTaskID() const;
	void SetCommsTaskID(const int newValue);

	const int GetSleepTime() const;
	void SetSleepTime(const int newValue);

	const int GetRetries() const;
	void SetRetries(const int newValue);

	const int GetRetryRate() const;
	void SetRetryRate(const int newValue);

	const int GetTimeoutSeconds() const;
	void SetTimeoutSeconds(const int newValue);

	VirtualRelayMessageManagerSettings& GetMessageManagerSettings();
	void SetMessageManagerSettings(const VirtualRelayMessageManagerSettings& newValue);

	void Load(const string& fileName);
	void Save(const string& fileName) const;

private:

	friend class boost::serialization::access;

	template<class Archive>
	void serialize(Archive & ar, const unsigned int version)
	{
		ar & BOOST_SERIALIZATION_NVP(host);
		ar & BOOST_SERIALIZATION_NVP(hostPort);
		ar & BOOST_SERIALIZATION_NVP(commsTaskID);
		ar & BOOST_SERIALIZATION_NVP(sleepTime);
		ar & BOOST_SERIALIZATION_NVP(retries);
		ar & BOOST_SERIALIZATION_NVP(retryRate);
		ar & BOOST_SERIALIZATION_NVP(timeoutSeconds);
		ar & BOOST_SERIALIZATION_NVP(messageManagerSettings);
	}

	string host;
	int hostPort;
	int commsTaskID;
	int sleepTime;
	int retries;
	int retryRate;
	int timeoutSeconds;
	VirtualRelayMessageManagerSettings messageManagerSettings;
};

}
}

BOOST_CLASS_VERSION(LiquidRobotics::VirtualRelay::VirtualRelayControllerSettings, 1)

#endif
