PixelLightAPI  .
FrontendApplication.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: FrontendApplication.h                          *
00003  *
00004  *  Copyright (C) 2002-2012 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_APPLICATION_H__
00024 #define __PLCORE_APPLICATION_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/Frontend/Frontend.h"
00032 #include "PLCore/Application/CoreApplication.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLCore {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Forward declarations                                  ]
00043 //[-------------------------------------------------------]
00044 class Frontend;
00045 
00046 
00047 //[-------------------------------------------------------]
00048 //[ Classes                                               ]
00049 //[-------------------------------------------------------]
00050 /**
00051 *  @brief
00052 *    Frontend application class
00053 *
00054 *  @remarks
00055 *    As the name of this class indicates, this is the base class for applications running
00056 *    within a frontend (the application host). The main loop as well as other logic is handed
00057 *    over to a host in order to become passive. Although a frontend application is always
00058 *    running within a frontend, it shouldn't care about the frontend. Just write our application
00059 *    as if there wouldn't be any "outer world". By following this philosophy as close as possible
00060 *    and only accessing frontend features when really necessary, you enhance the chance that your
00061 *    application can be embedded within other applications like browsers such as MS Internet Explorer
00062 *    or Mozilla Firefox without problems.
00063 */
00064 class FrontendApplication : public CoreApplication, protected AbstractFrontend {
00065 
00066 
00067     //[-------------------------------------------------------]
00068     //[ Friends                                               ]
00069     //[-------------------------------------------------------]
00070     friend class FrontendPixelLight;
00071 
00072 
00073     //[-------------------------------------------------------]
00074     //[ RTTI interface                                        ]
00075     //[-------------------------------------------------------]
00076     pl_class(PLCORE_RTTI_EXPORT, FrontendApplication, "PLCore", PLCore::CoreApplication, "Frontend application class")
00077         #ifdef PLCORE_EXPORTS   // The following is only required when compiling PLCore
00078             // Methods
00079             pl_method_0(GetFrontend,    pl_ret_type(Frontend&), "Returns the frontend this application is running in.", "")
00080         #endif
00081     pl_class_end
00082 
00083 
00084     //[-------------------------------------------------------]
00085     //[ Public functions                                      ]
00086     //[-------------------------------------------------------]
00087     public:
00088         /**
00089         *  @brief
00090         *    Returns the frontend this application is running in
00091         *
00092         *  @return
00093         *    Frontend this application instance is running in
00094         *
00095         *  @note
00096         *    - Try to avoid to access the frontend whenever possible (Hollywood Principle: "Don't call us, we'll call you")
00097         */
00098         inline Frontend &GetFrontend() const;
00099 
00100 
00101     //[-------------------------------------------------------]
00102     //[ Protected functions                                   ]
00103     //[-------------------------------------------------------]
00104     protected:
00105         /**
00106         *  @brief
00107         *    Constructor
00108         *
00109         *  @param[in] cFrontend
00110         *    Frontend this application instance is running in
00111         *
00112         *  @note
00113         *    - This constructor sets the default application name and title by using the name of the frontend executable ("GetFrontend().GetContext().GetName()")
00114         */
00115         PLCORE_API FrontendApplication(Frontend &cFrontend);
00116 
00117         /**
00118         *  @brief
00119         *    Destructor
00120         */
00121         PLCORE_API virtual ~FrontendApplication();
00122 
00123 
00124     //[-------------------------------------------------------]
00125     //[ Protected virtual AbstractLifecycle functions         ]
00126     //[-------------------------------------------------------]
00127     protected:
00128         /**
00129         *  @brief
00130         *    De-initialization function that is called after OnDeInit()
00131         *
00132         *  @remarks
00133         *    The default implementation does the following tasks:
00134         *    - Get frontend position and size of the current session and write frontend configuration
00135         *    - Everything that CoreApplication::OnStop() does
00136         */
00137         PLCORE_API virtual void OnStop() override;
00138 
00139 
00140     //[-------------------------------------------------------]
00141     //[ Protected virtual AbstractFrontend functions          ]
00142     //[-------------------------------------------------------]
00143     protected:
00144         /**
00145         *  @brief
00146         *    Called when the window size has been changed
00147         *
00148         *  @note
00149         *    - The default implementation is empty
00150         */
00151         PLCORE_API virtual void OnSize() override;
00152 
00153         /**
00154         *  @brief
00155         *    Called when the fullscreen mode was changed
00156         *
00157         *  @remarks
00158         *    This method just says "something related to fullscreen mode has been changed". Whether we
00159         *    changed from window mode into fullscreen mode or changed e.g. the resolution used in
00160         *    fullscreen mode is not really interesting in here.
00161         *
00162         *  @note
00163         *    - The default implementation is empty
00164         */
00165         PLCORE_API virtual void OnFullscreenMode() override;
00166 
00167         /**
00168         *  @brief
00169         *    Called to let the frontend draw into it's window
00170         *
00171         *  @note
00172         *    - The default implementation is empty
00173         */
00174         PLCORE_API virtual void OnDraw() override;
00175 
00176         /**
00177         *  @brief
00178         *    Called to let the frontend update it's states
00179         *
00180         *  @remarks
00181         *    You can use this method to do work you have to perform on a regular basis. It's
00182         *    recommended to keep the work done within the implementation as compact as possible.
00183         *    Don't use this function to perform 'polling'-everything, use events or if required
00184         *    for example timers or threads instead.
00185         *
00186         *  @note
00187         *    - The default implementation is empty
00188         */
00189         PLCORE_API virtual void OnUpdate() override;
00190 
00191         /**
00192         *  @brief
00193         *    Called when string data has been dropped onto the frontend window
00194         *
00195         *  @param[in] lstFiles
00196         *    List of file names
00197         *
00198         *  @note
00199         *    - The default implementation is empty
00200         */
00201         PLCORE_API virtual void OnDrop(const Container<String> &lstFiles) override;
00202 
00203 
00204     //[-------------------------------------------------------]
00205     //[ Protected virtual CoreApplication functions           ]
00206     //[-------------------------------------------------------]
00207     protected:
00208         /**
00209         *  @brief
00210         *    Called when application should initialize it's configuration
00211         *
00212         *  @remarks
00213         *    The default implementation does the following tasks:
00214         *    - Everything that CoreApplication::OnInitConfig() does
00215         *    - Read frontend configuration and set frontend position and size of the previous session
00216         *
00217         *  @note
00218         *    - Part of the application framework initialization function "OnStart()"
00219         */
00220         PLCORE_API virtual void OnInitConfig() override;
00221 
00222         /**
00223         *  @brief
00224         *    Called when application should load it's plugins
00225         *
00226         *  @remarks
00227         *    The default implementation does the following tasks:
00228         *    - Scan for plugins in application executable directory non-recursively
00229         *    - If the application executable directory is not the same as the application startup directory, scan for plugins in application startup directory non-recursively
00230         *
00231         *  @note
00232         *    - Part of the application framework initialization function "OnStart()"
00233         */
00234         PLCORE_API virtual void OnInitPlugins() override;
00235 
00236         /**
00237         *  @brief
00238         *    Called when application should set it's data paths
00239         *
00240         *  @remarks
00241         *    The default implementation does the following tasks:
00242         *    - Set '.' as base path in LoadableManager
00243         *    - Scan for packages in "Data/" directory
00244         *    - Set application directory as base path in LoadableManager
00245         *    - Scan for packages in application directory "Data/" directory
00246         *    - Get current language and load PixelLight localization file, if no language is defined, English is used as default
00247         *
00248         *  @note
00249         *    - Part of the application framework initialization function "OnStart()"
00250         */
00251         PLCORE_API virtual void OnInitData() override;
00252 
00253 
00254     //[-------------------------------------------------------]
00255     //[ Private data                                          ]
00256     //[-------------------------------------------------------]
00257     private:
00258         Frontend *m_pFrontend;  /**< Frontend the application is running in, always valid! */
00259 
00260 
00261 };
00262 
00263 
00264 //[-------------------------------------------------------]
00265 //[ Namespace                                             ]
00266 //[-------------------------------------------------------]
00267 } // PLCore
00268 
00269 
00270 //[-------------------------------------------------------]
00271 //[ Implementation                                        ]
00272 //[-------------------------------------------------------]
00273 #include "PLCore/Frontend/FrontendApplication.inl"
00274 
00275 
00276 #endif // __PLCORE_APPLICATION_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:54
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported