//-------------------------------------------------------------------------------------------------
// <copyright file="LWProgramSettings.cpp" company="LiquidRobotics">
//  Copyright (c) Liquid Robotics Corporation, confidential and proprietary.  All rights reserved. 
// </copyright>
//
// <summary>
//	Implementation of LWProgramSettings, a boost serializable entity class that
//	holds the configurable settings for LWProgram.
// </summary>
//
// <owner>Mike Cookson</owner>
//-------------------------------------------------------------------------------------------------

#include "LWProgramSettings.h"
#include "LqrSMACLoadSaveBoostXml.h"

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

namespace LiquidRobotics {
namespace LuaWrapper {

LWProgramSettings::LWProgramSettings()
{
	sensorProgramSettings.SetServerName("LuaWrapper");
}

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

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

	return *this;
}

const LWControllerSettings& LWProgramSettings::GetControllerSettings() const
{
	return controllerSettings;
}

void LWProgramSettings::SetControllerSettings(LWControllerSettings& newValue)
{
	controllerSettings = newValue;
}

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

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

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

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

}
}
