//-------------------------------------------------------------------------------------------------
// <copyright file="PayloadManager.h" company="LiquidRobotics">
//  Copyright (c) Liquid Robotics Corporation, confidential and proprietary.  All rights reserved. 
// </copyright>
//
// <summary>
// 	Declarations for PayloadManager, the controller class that implements the
//  IPayloadManagerProcess interface.
// </summary>
//
// <owner>Mike Cookson</owner>
//-------------------------------------------------------------------------------------------------

#ifndef __PAYLOADMANAGER_H__
#define __PAYLOADMANAGER_H__

#include "PayloadManagerSettings.h"
#include "IEventBase.h"
#include "EventTransceiver.h"
#include "LqrSMACIdl.h"
#include "LqrSMACLogger.h"
#include "LqrSMACIObjectBroker.h"
#include "LqrSMACPayloadDescription.h"
#include "LqrSMACPayloadDescriptionList.h"
#include "LqrSMACSharedLib.h"
#include <map>
#include <string>

class SHARED_LIB_PUBLIC PayloadManager
: public LiquidRobotics::EventLib::EventTransceiver
, public LiquidRobotics::SMACFramework::ICommandableBase
{
public:

	typedef LiquidRobotics::EventLib::IEventBase IEventBase;
	typedef LiquidRobotics::EventLib::EventTransceiver EventTransceiver;
	typedef LiquidRobotics::EventLib::EventType EventType;
	typedef EventTransceiver::Settings EventTransceiverSettings;
	typedef LiquidRobotics::SMACFramework::IObjectBroker IObjectBroker;
	typedef LiquidRobotics::SMACFramework::Logger Logger;
	typedef std::string string;
	typedef LiquidRobotics::SMACFramework::PayloadDescription Desc;
	typedef LiquidRobotics::SMACFramework::PayloadDescription::Ptr DescPtr;
	typedef LiquidRobotics::SMACFramework::PayloadDescriptionList DescList;


	PayloadManager(IObjectBroker& _broker, const PayloadManagerSettings& _settings, Logger& _logger);
	virtual ~PayloadManager();

	virtual void Initialize(Object_ptr _pServer);

	// IPingable operations
    virtual ::CORBA::Double Ping();

    // IPayloadManager
    void Register(const LiquidRobotics::SMAC::PayloadDescription& payload, ::CORBA::Boolean overwrite);
    void Unregister(const char* ior);
    LiquidRobotics::SMAC::BoardIDType defaultBoardID();
    LiquidRobotics::SMAC::PayloadDescriptionList* payloadDescriptions();

    // ICommandable
    void SendCommand(const ::CORBA::Any& command, const char* requester, const char* transactionID, ::CORBA::Any_OUT_arg result);

private:

	void FireRegistrationEvent(const string& eventName, const Desc& pyldDesc);

	IObjectBroker& broker;
	Logger& logger;
	PayloadManagerSettings settings;
	DescList payloadList;
};

#endif
