//-------------------------------------------------------------------------------------------------
// <copyright file="SEProgramSettings.cpp" company="LiquidRobotics">
//  Copyright (c) Liquid Robotics Corporation, confidential and proprietary.  All rights reserved. 
// </copyright>
//
// <summary>
// 	Implementation of SEProgramSettings, a serialiable entity that holds the
//  settings for an example sensor Program class.
// </summary>
//
// <owner>Mike Cookson</owner>
//-------------------------------------------------------------------------------------------------

#include "SEProgramSettings.h"
#include "LqrSMACLoadSaveBoostXml.h"

using namespace std;
using namespace LiquidRobotics::SMACFramework;
using namespace LiquidRobotics::EventLib;

namespace LiquidRobotics {
namespace SensorExample {

SEProgramSettings::SEProgramSettings()
: tagEventSettings("SETagReport", "StringEvent", "LiquidR-SMC")
{
	sensorProgramSettings.SetServerName("SE");
}

SEProgramSettings::SEProgramSettings(const SEProgramSettings& rhs)
: sensorProgramSettings(rhs.sensorProgramSettings)
, controllerSettings(rhs.controllerSettings)
, tagEventSettings(rhs.tagEventSettings)
{
}

SEProgramSettings& SEProgramSettings::operator=(const SEProgramSettings& rhs)
{
	if (this != &rhs)
	{
		sensorProgramSettings = rhs.sensorProgramSettings;
		controllerSettings = rhs.controllerSettings;
		tagEventSettings = rhs.tagEventSettings;
	}

	return *this;
}

const SEControllerSettings& SEProgramSettings::GetControllerSettings() const
{
	return controllerSettings;
}

void SEProgramSettings::SetControllerSettings(SEControllerSettings& newValue)
{
	controllerSettings = newValue;
}

const SensorProgramSettings& SEProgramSettings::GetSensorProgramSettings() const
{
	return sensorProgramSettings;
}

void SEProgramSettings::SetSensorProgramSettings(const SensorProgramSettings& newValue)
{
	sensorProgramSettings = newValue;
}

const EventSettings& SEProgramSettings::GetTagEventSettings() const
{
	return tagEventSettings;
}

void SEProgramSettings::SetTagEventSettings(const EventSettings& newValue)
{
	tagEventSettings = newValue;
}


void SEProgramSettings::Load(const string& fileName, bool withMD5)
{
	if (withMD5)
		LoadBoostXmlMD5(fileName, *this, true);
	else
		LoadBoostXml(fileName, *this);
}

void SEProgramSettings::Save(const string& fileName, bool withMD5) const
{
	if (withMD5)
		SaveBoostXmlMD5(fileName, *this, true);
	else
		SaveBoostXml(fileName, *this);
}

}
}
