Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members

ActionEngine.h

Go to the documentation of this file.
00001 /*********************************************************************************
00002  *
00003  * Razor! Engine - A modular C++ presentation engine
00004  *
00005  * $Id: ActionEngine.h,v 1.3 2003/03/17 22:16:24 teacy Exp $
00006  *
00007  * Copyright (c) 2000-2003 Tilo Christ. All Rights Reserved.
00008  *
00009  * Permission is hereby granted, free of charge, to any person obtaining a 
00010  * copy of this software and associated documentation files (the  "Software"), 
00011  * to deal in the Software without restriction, including without limitation 
00012  * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
00013  * and/or sell copies of the Software, and to permit persons to whom the Software 
00014  * is furnished to do so, subject to the following conditions:
00015  *
00016  * The above copyright notice and this permission notice shall be included in all 
00017  * copies or substantial portions of the Software.
00018  *
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
00020  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
00021  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
00022  * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
00023  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00024  *
00025  **********************************************************************************/
00026 
00027 
00028 #ifndef ACTIONENGINE_H
00029 #define ACTIONENGINE_H
00030 
00031 #include "Sections.h"
00032 #include <PalmOS.h>
00033 
00034 #include "StateDescriptor.h"
00035 #include "Screen.h"
00036 
00037 
00038 /**
00039  * The base class for a game.
00040  * <br>
00041  * Defines the sequence of screens, and takes care of persistence.
00042  */
00043 class ActionEngine
00044 {
00045     public:
00046 /// @name Lifecycle management
00047 //@{
00048     /**
00049      * Construct a new ActionEngine
00050      */
00051     ActionEngine(UInt16 numStateDescriptors) SEC_GAME; 
00052 
00053 
00054     /**
00055      * Destroy the ActionEngine
00056      */
00057     virtual ~ActionEngine() SEC_GAME = 0;
00058 //@}
00059 
00060     
00061 /// @name Control flow
00062 //@{
00063     /**
00064      * Initialize the ActionEngine and all Screens.
00065      * Make sure you set the persistent state of the ActionEngine and
00066      * all Screens to working default values.
00067      */
00068     virtual void init() SEC_GAME = 0;
00069 
00070     /**
00071      * Get the currently needed Screen
00072      * Ownership of the screen is transferred to the caller.
00073      */
00074      virtual Screen* getCurrentScreen() const SEC_GAME = 0;
00075 
00076     /**
00077      * Get the next Screen in the sequence of Screens.
00078      * Ownership of the screen is transferred to the caller.
00079      */
00080      virtual Screen *getNextScreen() SEC_GAME = 0;
00081 //@}
00082 
00083 
00084 /// @name Persistence
00085 //@{
00086     /**
00087      * The version number of the application state. 
00088      *
00089      * This should be increased by 1 every time the application's 
00090      * state descriptor layout changes. 
00091      *
00092      * @return a version number 
00093      */ 
00094     virtual UInt16 getStateDescriptorsVersion() const SEC_GAME = 0;
00095     
00096 
00097     /**
00098      * Return the nth state descriptor for this ActionEngine.
00099      * Ownership of the descriptor remains with the ActionEngine.
00100      *
00101      * @return a StateDescriptor
00102      */  
00103     StateDescriptor *getStateDescriptor(UInt16 index) const SEC_GAME;
00104 //@}
00105 
00106 
00107 /// @name Miscellaneous
00108 //@{
00109     virtual Boolean getPreventAutoOff() const SEC_GAME;
00110 //@}
00111 
00112 
00113     protected:
00114     StateDescriptorPtr *stateDescriptors;
00115 
00116     private:
00117     UInt16 numStateDescriptors;
00118 };
00119 
00120 
00121 
00122 #define MYACTIONENGINE_PUBLIC_OPS  \
00123     MyActionEngine() SEC_GAME;  \
00124     ~MyActionEngine() SEC_GAME; \
00125     void init() SEC_GAME; \
00126     Screen *getCurrentScreen() const SEC_GAME; \
00127     Screen *getNextScreen() SEC_GAME; \
00128 \
00129     UInt16 getStateDescriptorsVersion() const SEC_GAME;
00130 
00131 
00132 
00133 
00134 
00135 #endif

Razor! Engine Developer's Guide. Copyright © by Tilo Christ. All Rights Reserved. Last updated: 31 May 2003