//-------------------------------------------------------------------------------------------------
// <copyright file="AlarmReporterSettings.h" company="LiquidRobotics">
//  Copyright (c) Liquid Robotics Corporation, confidential and proprietary.  All rights reserved.
// </copyright>
//
// <summary>
// 	Declarations for AlarmReporterSettings, a serializable entity that holds the
//  settings for an alarm's unique "reporter type ID" and name.
// </summary>
//
// <owner>Andrew Trapani</owner>
//-------------------------------------------------------------------------------------------------

#ifndef __EVENTLIB_ALARMREPORTERSETTINGS_H__
#define __EVENTLIB_ALARMREPORTERSETTINGS_H__

#include "LqrSMACSharedLib.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 EventLib {

/* The Reporter Type ID is defined in the ICD ship to shore
 * Email Ehud.Prado@liquidr.com
 * SMC alarms will start at AlarmMessage's payloadReporterTypeMinimum
 * AlarmReporterSettings allows the user to configure the reporterTypeID and a reporter name
 * on a process by process basis. It will print a warning and not send an alarm
 * when the reporter Type ID chosen by
 */
class SHARED_LIB_PUBLIC AlarmReporterSettings
{
public:

	typedef std::string string;

	AlarmReporterSettings();
	AlarmReporterSettings(const AlarmReporterSettings& rhs);

	AlarmReporterSettings& operator=(const AlarmReporterSettings& rhs);

	const int GetReporterTypeId() const;
	void SetReporterTypeId(const int newValue);

	const string GetReporterName() const;
	void SetReporterName(const string newValue);

	const unsigned int GetMinTime() const;
	void SetMinTime(const unsigned int 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(reporterTypeId);
		ar & BOOST_SERIALIZATION_NVP(reporterName);
		if (version > 1) { ar & BOOST_SERIALIZATION_NVP(minTimeBetweenOneTimeAlarmsMinutes); }
	}

	template<class Archive>
	void save(Archive & ar, const unsigned int version) const
	{
		ar & BOOST_SERIALIZATION_NVP(reporterTypeId);
		ar & BOOST_SERIALIZATION_NVP(reporterName);
		if (version > 1) { ar & BOOST_SERIALIZATION_NVP(minTimeBetweenOneTimeAlarmsMinutes); }
	}

	BOOST_SERIALIZATION_SPLIT_MEMBER()

	int reporterTypeId;
	string reporterName;
	unsigned int minTimeBetweenOneTimeAlarmsMinutes; //minutes
};

}
}

BOOST_CLASS_VERSION(LiquidRobotics::EventLib::AlarmReporterSettings, 2)

#endif
