1 //------------------------------------------------------------------------------
2 // File : SkyControlled.hpp
3 //------------------------------------------------------------------------------
4 // SkyWorks : Copyright 2002 Mark J. Harris and
5 // The University of North Carolina at Chapel Hill
6 //------------------------------------------------------------------------------
7 // Permission to use, copy, modify, distribute and sell this software and its
8 // documentation for any purpose is hereby granted without fee, provided that
9 // the above copyright notice appear in all copies and that both that copyright
10 // notice and this permission notice appear in supporting documentation.
11 // Binaries may be compiled with this software without any royalties or
14 // The author(s) and The University of North Carolina at Chapel Hill make no
15 // representations about the suitability of this software for any purpose.
16 // It is provided "as is" without express or
19 * @file SkyControlled.hpp
21 * Interface definition for controlled objects.
23 #ifndef __SKYCONTROLLED_HPP__
24 #define __SKYCONTROLLED_HPP__
26 //#include "BHXController.hpp"
28 template<typename ControlStateType> class SkyController;
31 //------------------------------------------------------------------------------
33 * @class SkyControlled
34 * @brief A base class defining an interface for controlled objects.
36 * This class abstracts the control of objects into a simple interface that a
37 * class may inherit that allows it to be controlled by SkyController objects.
38 * A class simply inherits from SkyControlled, which forces the class to implement
39 * the method UpdateStateFromControls(). This method usually uses the SkyController
40 * object passed to SetController() to query the input state via
41 * SkyController::GetControlState().
45 template<typename ControlStateType>
50 SkyControlled() { _pController = NULL; }
52 virtual ~SkyControlled() { _pController = NULL; }
54 //! Sets the controller which will control this controlled object.
55 void SetController(SkyController<ControlStateType> *pController) { _pController = pController; }
57 //! Updates the state of the controlled object based on the controls (received from the controller).
58 virtual SKYRESULT UpdateStateFromControls(SKYTIME timeStep) = 0;
61 SkyController<ControlStateType> *_pController;
62 ControlStateType _controlState;
65 #endif //__SKYCONTROLLED_HPP__