//------------------------------------------------------------------------------
// <copyright file="LqrSMACPayloadDescription.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 PayloadDescription, an entity class that stands in for the
//  IDL generated description class.
// </summary>
//
// <owner>Mike Cookson</owner>
//------------------------------------------------------------------------------

#ifndef __LQRSMACPAYLOADDESCRIPTION_H__
#define __LQRSMACPAYLOADDESCRIPTION_H__

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

namespace LiquidRobotics {
namespace SMACFramework {

class SHARED_LIB_PUBLIC PayloadDescription
{
public:

	typedef LiquidRobotics::SMAC::PayloadDescription CORBAEntity;
	typedef LiquidRobotics::SMAC::PayloadDescription_var CORBAEntity_var;
	typedef LiquidRobotics::SMAC::BoardIDType BoardIDType;
	typedef boost::shared_ptr<PayloadDescription> Ptr;
	typedef LiquidRobotics::SMAC::TaskIDType TaskIDType;
	typedef std::string string;

	PayloadDescription();
	PayloadDescription(const PayloadDescription& other);
	PayloadDescription(const CORBAEntity& entity);

	PayloadDescription& operator=(const PayloadDescription& other);
	PayloadDescription& operator=(const CORBAEntity& entity);

	bool operator==(const PayloadDescription& other) const;
	bool operator<(const PayloadDescription& other) const;

	CORBAEntity_var GetEntity() const;
	void SetEntity(const CORBAEntity& newValue);

	BoardIDType GetBoardID() const;
	void SetBoardID(BoardIDType newValue);

	TaskIDType GetTaskID() const;
	void SetTaskID(TaskIDType newValue);

	const string& GetDescription() const;
	void SetDescription(const string& newValue);

	const string& GetIOR() const;
	void SetIOR(const string& newValue);

	const string& GetReadableName() const;
	void SetReadableName(const string& newValue);

	const string& GetDescriptiveJSON() const;
	void SetDescriptiveJSON(const string& newValue);

private:

	friend class boost::serialization::access;

	template<class Archive>
	void load(Archive & ar, const unsigned int version)
	{
		ar & BOOST_SERIALIZATION_NVP(boardID);
		ar & BOOST_SERIALIZATION_NVP(taskID);
		ar & BOOST_SERIALIZATION_NVP(description);
		ar & BOOST_SERIALIZATION_NVP(ior);
		ar & BOOST_SERIALIZATION_NVP(readableName);
		if (version >= 2)
			ar & BOOST_SERIALIZATION_NVP(descriptiveJSON);
	}

	template<class Archive>
	void save(Archive & ar, const unsigned int version) const
	{
		ar & BOOST_SERIALIZATION_NVP(boardID);
		ar & BOOST_SERIALIZATION_NVP(taskID);
		ar & BOOST_SERIALIZATION_NVP(description);
		ar & BOOST_SERIALIZATION_NVP(ior);
		ar & BOOST_SERIALIZATION_NVP(readableName);
		ar & BOOST_SERIALIZATION_NVP(descriptiveJSON);
	}

	BOOST_SERIALIZATION_SPLIT_MEMBER()

	int compare(const PayloadDescription& other) const;

	BoardIDType boardID;
	TaskIDType taskID;
	string description;
	string ior;
	string readableName;
	string descriptiveJSON;
};

std::ostream& operator<<(std::ostream& out, const PayloadDescription& pyldDesc);

}
}

BOOST_CLASS_VERSION(LiquidRobotics::SMACFramework::PayloadDescription, 2)

#endif
