1 /*****************************************************************************
2  * $LastChangedDate: 2011-04-09 21:58:06 -0400 (Sat, 09 Apr 2011) $
3  * @file
4  * @author  Jim E. Brooks  http://www.palomino3d.org
5  * @brief   Events for controlling an Aircraft.
6  *//*
7  * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
8  *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
9  *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
10  *****************************************************************************/
11 
12 #ifndef CONTROL_EVENTS_HH
13 #define CONTROL_EVENTS_HH 1
14 
15 #include "base/singleton.hh"
16 #include "base/event.hh"
17 using namespace base;
18 #include "object/module.hh"
19 #include "object/aircraft.hh"
20 using namespace object;
21 #include "control/command.hh"
22 
23 namespace control {
24 
25 /// @brief Pairs an Aircraft with its Command.
26 struct CommandEvent
27 {
CommandEventcontrol::CommandEvent28     CommandEvent( shptr<Aircraft> aircraft, shptr<Command> command )
29     : mAircraft(aircraft), mCommand(command) { }
30     shptr<Aircraft> mAircraft;
31     shptr<Command>  mCommand;
32 };
33 
34 ////////////////////////////////////////////////////////////////////////////////
35 /// @brief Events for controlling an Aircraft.
36 ///
37 class Events
38 {
39 public:
DEFINE_GetInstance(Events)40     DEFINE_GetInstance( Events )  // Singleton
41 
42 #define EVENT_CONTROL_COMMAND control::Events::GetInstance().GetCommandEvent()
43     Event<CommandEvent>&    GetCommandEvent( void ) { return mCommandEvent; }
44 
45 private:
46     CLASS_VAR Events*       msInstance;
47     Event<CommandEvent>     mCommandEvent;
48 };
49 
50 #if CONTROL_MODULE_CC
51 Events* Events::msInstance;
52 #endif
53 
54 } // namespace control
55 
56 #endif // CONTROL_EVENTS_HH
57