/*****************************************************************************
 * $LastChangedDate: 2011-04-09 21:58:06 -0400 (Sat, 09 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Events for controlling an Aircraft.
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef CONTROL_EVENTS_HH
#define CONTROL_EVENTS_HH 1

#include "base/singleton.hh"
#include "base/event.hh"
using namespace base;
#include "object/module.hh"
#include "object/aircraft.hh"
using namespace object;
#include "control/command.hh"

namespace control {

/// @brief Pairs an Aircraft with its Command.
struct CommandEvent
{
    CommandEvent( shptr<Aircraft> aircraft, shptr<Command> command )
    : mAircraft(aircraft), mCommand(command) { }
    shptr<Aircraft> mAircraft;
    shptr<Command>  mCommand;
};

////////////////////////////////////////////////////////////////////////////////
/// @brief Events for controlling an Aircraft.
///
class Events
{
public:
    DEFINE_GetInstance( Events )  // Singleton

#define EVENT_CONTROL_COMMAND control::Events::GetInstance().GetCommandEvent()
    Event<CommandEvent>&    GetCommandEvent( void ) { return mCommandEvent; }

private:
    CLASS_VAR Events*       msInstance;
    Event<CommandEvent>     mCommandEvent;
};

#if CONTROL_MODULE_CC
Events* Events::msInstance;
#endif

} // namespace control

#endif // CONTROL_EVENTS_HH
