//-------------------------------------------------------------------------------
// <copyright file="TelemetryConfig.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 StorageController, a control class that implements storage,
//   listing, reading and writing of a set of files that have WGMS properties.
// </summary>
//
// <owner>Mike Cookson</owner>
//-------------------------------------------------------------------------------

#ifndef __PAYLOADINTERFACELIB_TELEMETRYCONFIG_H__
#define __PAYLOADINTERFACELIB_TELEMETRYCONFIG_H__

#include <map>
#include <ostream>
#include <string>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
#include "LqrSMACByteArray.h"
#include "LqrSMACSharedLib.h"
#include "PayloadMessage.h"

namespace LiquidRobotics {

namespace EventLib
{
	class EventPropertyValue;
	class IEventBase;
}

namespace SMACFramework
{
	class IObjectBroker;
}

// BoardID
// TaskID
// EventName
// MaxSamples
// MaxRetainTime
// TelemetryFieldList header
// TelemetryFieldList body


namespace PayloadInterface {

class SHARED_LIB_PUBLIC TelemetrySample
{
public:


};





class SHARED_LIB_PUBLIC TelemetryConfig
{
public:

	typedef LiquidRobotics::SMACFramework::ByteArray ByteArray;
	typedef LiquidRobotics::EventLib::IEventBase IEventBase;
	typedef LiquidRobotics::SMACFramework::IObjectBroker IObjectBroker;
	typedef boost::signals2::signal<void (TelemetryConfig& sender, const IEventBase& event, const ByteArray& data)> TelemetryResultSignalType;
	typedef TelemetryResultSignalType::slot_type TelemetryResultSignalSlotType;
	typedef boost::signals2::scoped_connection ScopedConnection;
	typedef boost::shared_ptr<ScopedConnection> ScopedConnectionPtr;
	typedef std::string string;

	TelemetryConfig(IObjectBroker& _broker);
	TelemetryConfig(const TelemetryConfig& other);

	TelemetryConfig& operator=(const TelemetryConfig& other);

	bool operator==(const TelemetryConfig& other) const;

	void Load(const string& fileName);
	void ReceivedEvent(const IEventBase& evt);
	void Save(const string& fileName) const;
	ScopedConnectionPtr Subscribe(const TelemetryResultSignalSlotType& slot);

private:

	IObjectBroker& broker;
	TelemetryResultSignalType telemSignal;
};

#endif
