PixelLightAPI  .
AbstractLifecycle.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: AbstractLifecycle.h                            *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLCORE_ABSTRACTLIFECYCLE_H__
00024 #define __PLCORE_ABSTRACTLIFECYCLE_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Namespace                                             ]
00030 //[-------------------------------------------------------]
00031 namespace PLCore {
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Classes                                               ]
00036 //[-------------------------------------------------------]
00037 /**
00038 *  @brief
00039 *    Abstract life cycle class
00040 *
00041 *  @remarks
00042 *  @verbatim
00043 *    The "Life cycle" is:
00044 *      "OnCreate()"         - Called directly after the object has been created
00045 *        ("OnRestart()")    - Called directly before a stopped object is going to start again (always followed by "OnStart()")
00046 *        "OnStart()"        - Called when the object becoming visible to the user
00047 *          "OnResume()"     - Called when the object has the focus (keep the implementation lightweight)
00048 *          "OnPause()"      - Called when the object has no longer the focus (keep the implementation lightweight)
00049 *        "OnStop()"         - Called when the object is no longer visible to the user
00050 *      "OnDestroy()"        - Called before the object is going to be finally destroyed
00051 *    This life cycle has the same interface as the "Android Activity Life cycle"
00052 *    (http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle)
00053 *    because this interface looks just the right way to go for this purpose... also there
00054 *    are nice diagrams and documentations explaining the interface so it shouldn't be to
00055 *    hard to understand it.
00056 *  @endverbatim
00057 */
00058 class AbstractLifecycle {
00059 
00060 
00061     //[-------------------------------------------------------]
00062     //[ Public virtual AbstractLifecycle functions            ]
00063     //[-------------------------------------------------------]
00064     public:
00065         /**
00066         *  @brief
00067         *    Called directly after the object has been created
00068         */
00069         virtual void OnCreate() = 0;
00070 
00071         /**
00072         *  @brief
00073         *    Called directly before a stopped object is going to start again (always followed by "OnStart()")
00074         */
00075         virtual void OnRestart() = 0;
00076 
00077         /**
00078         *  @brief
00079         *    Called when the object becoming visible to the user
00080         *
00081         *  @return
00082         *    'true' if all went fine, else 'false' (on failure, no "OnResume()", "OnPause()" or "OnStop()" will be called)
00083         */
00084         virtual bool OnStart() = 0;
00085 
00086         /**
00087         *  @brief
00088         *    Called when the object has the focus (keep the implementation lightweight)
00089         */
00090         virtual void OnResume() = 0;
00091 
00092         /**
00093         *  @brief
00094         *    Called when the object has no longer the focus (keep the implementation lightweight)
00095         */
00096         virtual void OnPause() = 0;
00097 
00098         /**
00099         *  @brief
00100         *    Called when the object is no longer visible to the user
00101         */
00102         virtual void OnStop() = 0;
00103 
00104         /**
00105         *  @brief
00106         *    Called before the object is going to be finally destroyed
00107         */
00108         virtual void OnDestroy() = 0;
00109 
00110 
00111     //[-------------------------------------------------------]
00112     //[ Protected functions                                   ]
00113     //[-------------------------------------------------------]
00114     protected:
00115         /**
00116         *  @brief
00117         *    Default constructor
00118         */
00119         AbstractLifecycle();
00120 
00121         /**
00122         *  @brief
00123         *    Destructor
00124         */
00125         virtual ~AbstractLifecycle();
00126 
00127 
00128     //[-------------------------------------------------------]
00129     //[ Private functions                                     ]
00130     //[-------------------------------------------------------]
00131     private:
00132         /**
00133         *  @brief
00134         *    Copy constructor
00135         *
00136         *  @param[in] cSource
00137         *    Source to copy from
00138         */
00139         AbstractLifecycle(const AbstractLifecycle &cSource);
00140 
00141         /**
00142         *  @brief
00143         *    Copy operator
00144         *
00145         *  @param[in] cSource
00146         *    Source to copy from
00147         *
00148         *  @return
00149         *    Reference to this instance
00150         */
00151         AbstractLifecycle &operator =(const AbstractLifecycle &cSource);
00152 
00153 
00154 };
00155 
00156 
00157 //[-------------------------------------------------------]
00158 //[ Namespace                                             ]
00159 //[-------------------------------------------------------]
00160 } // PLCore
00161 
00162 
00163 #endif // __PLCORE_ABSTRACTLIFECYCLE_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:50
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported