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

#ifndef __PAYLOADINTERFACELIB_SV3NetInterfaceSettings_H__
#define __PAYLOADINTERFACELIB_SV3NetInterfaceSettings_H__

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

namespace LiquidRobotics {
namespace PayloadInterface {

class SHARED_LIB_PUBLIC SV3NetInterfaceSettings
{
public:

	typedef std::string string;

	SV3NetInterfaceSettings();
	SV3NetInterfaceSettings(const SV3NetInterfaceSettings& rhs);
	virtual ~SV3NetInterfaceSettings();

	SV3NetInterfaceSettings& operator=(const SV3NetInterfaceSettings& rhs);

	const string& GetHostAddress() const;
	void SetHostAddress(const string& newValue);

	const string& GetHostAddressVerb() const;
	void SetHostAddressVerb(const string& newValue);

	unsigned GetConnectTimeoutSec() const;
	void SetConnectTimeoutSec(unsigned newValue);

	unsigned GetTransactionTimeoutSec() const;
	void SetTransactionTimeoutSec(unsigned newValue);

private:

	friend class boost::serialization::access;

	template<class Archive>
	void load(Archive & ar, const unsigned int version)
	{
		ar & BOOST_SERIALIZATION_NVP(hostAddress);
		if (version >= 2)
			ar & BOOST_SERIALIZATION_NVP(hostAddressVerb);
		ar & BOOST_SERIALIZATION_NVP(connectTimeoutSec);
		ar & BOOST_SERIALIZATION_NVP(transactionTimeoutSec);
	}

	template<class Archive>
	void save(Archive & ar, const unsigned int version) const
	{
		ar & BOOST_SERIALIZATION_NVP(hostAddress);
		ar & BOOST_SERIALIZATION_NVP(hostAddressVerb);
		ar & BOOST_SERIALIZATION_NVP(connectTimeoutSec);
		ar & BOOST_SERIALIZATION_NVP(transactionTimeoutSec);
	}

	BOOST_SERIALIZATION_SPLIT_MEMBER()

	string hostAddress;							// address of the Host
	string hostAddressVerb;						// address of the Host
	unsigned connectTimeoutSec;				// connection timeout (seconds) when connecting to the Host
	unsigned transactionTimeoutSec;			// transaction timeout (seconds) for any web services call to the Host
};

SHARED_LIB_PUBLIC std::ostream& operator<<(std::ostream& stm, const SV3NetInterfaceSettings& settings);

}
}

BOOST_CLASS_VERSION(LiquidRobotics::PayloadInterface::SV3NetInterfaceSettings, 2)

#endif
