PixelLightAPI  .
SystemAndroid.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SystemAndroid.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_SYSTEM_ANDROID_H__
00024 #define __PLCORE_SYSTEM_ANDROID_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/Base/Event/Event.h"
00032 #include "PLCore/System/ConsoleAndroid.h"
00033 #include "PLCore/System/SystemLinux.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Forward declarations                                  ]
00038 //[-------------------------------------------------------]
00039 struct android_app;
00040 typedef struct android_app android_app;
00041 struct AAssetManager;
00042 typedef struct AAssetManager AAssetManager;
00043 struct AInputEvent;
00044 typedef struct AInputEvent AInputEvent;
00045 
00046 
00047 //[-------------------------------------------------------]
00048 //[ Namespace                                             ]
00049 //[-------------------------------------------------------]
00050 namespace PLCore {
00051 
00052 
00053 //[-------------------------------------------------------]
00054 //[ Classes                                               ]
00055 //[-------------------------------------------------------]
00056 /**
00057 *  @brief
00058 *    Android 'System' implementation
00059 */
00060 class SystemAndroid : public SystemLinux {
00061 
00062 
00063     //[-------------------------------------------------------]
00064     //[ Friends                                               ]
00065     //[-------------------------------------------------------]
00066     friend class System;
00067 
00068 
00069     //[-------------------------------------------------------]
00070     //[ Public static events                                  ]
00071     //[-------------------------------------------------------]
00072     public:
00073         static PLCORE_API Event<const struct AInputEvent&> EventInputEvent; /**< Android input event, input event to be processed as first parameter */
00074 
00075 
00076     //[-------------------------------------------------------]
00077     //[ Public static functions                               ]
00078     //[-------------------------------------------------------]
00079     public:
00080         /**
00081         *  @brief
00082         *    Returns the native Android application
00083         *
00084         *  @return
00085         *    The native Android application, can be a null pointer, do not delete the returned instance
00086         */
00087         static inline android_app *GetAndroidApp();
00088 
00089         /**
00090         *  @brief
00091         *    Sets the native Android application
00092         *
00093         *  @param[in] pAndroidApp
00094         *    Native Android application, can be a null pointer, the given instance is just shared and not destroyed by this class
00095         */
00096         static inline void SetAndroidApp(android_app *pAndroidApp);
00097 
00098         /**
00099         *  @brief
00100         *    Returns the Android asset manager
00101         *
00102         *  @return
00103         *    The Android asset manager, can be a null pointer, do not delete the returned instance
00104         *
00105         *  @note
00106         *    - Information can also be received thru the native Android application pointer received via "GetAndroidApp()"
00107         *      (native Android activity only, that's why this special asset manager method exists in here)
00108         */
00109         static inline AAssetManager *GetAssetManager();
00110 
00111         /**
00112         *  @brief
00113         *    Sets the Android asset manager
00114         *
00115         *  @param[in] pAAssetManager
00116         *    Android asset manager, can be a null pointer, the given instance is just shared and not destroyed by this class
00117         */
00118         static inline void SetAssetManager(AAssetManager *pAAssetManager);
00119 
00120         /**
00121         *  @brief
00122         *    Emit Android input event
00123         *
00124         *  @param[in] sAInputEvent
00125         *    Android input event to emit
00126         */
00127         static PLCORE_API void EmitInputEvent(const struct AInputEvent &sAInputEvent);
00128 
00129         /**
00130         *  @brief
00131         *    Returns whether or not console messages are also written into the Android in-kernel log buffer (use Androids "logcat" utility to access this system log)
00132         *
00133         *  @return
00134         *    'true' if console messages are also written into the Android in-kernel log buffer, else 'false'
00135         */
00136         static inline bool GetConsoleToKernelLog();
00137 
00138         /**
00139         *  @brief
00140         *    Sets whether or not console messages are also written into the Android in-kernel log buffer (use Androids "logcat" utility to access this system log)
00141         *
00142         *  @param[in] bConsoleToKernelLog
00143         *    'true' if console messages are also written into the Android in-kernel log buffer, else 'false', default is 'false'
00144         */
00145         static inline void SetConsoleToKernelLog(bool bConsoleToKernelLog);
00146 
00147 
00148     //[-------------------------------------------------------]
00149     //[ Private functions                                     ]
00150     //[-------------------------------------------------------]
00151     private:
00152         /**
00153         *  @brief
00154         *    Constructor
00155         */
00156         SystemAndroid();
00157 
00158         /**
00159         *  @brief
00160         *    Destructor
00161         */
00162         virtual ~SystemAndroid();
00163 
00164 
00165     //[-------------------------------------------------------]
00166     //[ Private virtual SystemImpl functions                  ]
00167     //[-------------------------------------------------------]
00168     private:
00169         virtual String GetPlatform() const override;
00170         virtual String GetModuleFilenameByMemoryAddress(const void *pMemoryAddress) const override;
00171         virtual const Console &GetConsole() const override;
00172         virtual void UrgentMessage(const String &sMessage) const override;
00173 
00174 
00175     //[-------------------------------------------------------]
00176     //[ Private static data                                   ]
00177     //[-------------------------------------------------------]
00178     private:
00179         static PLCORE_API android_app   *g_pAndroidApp;         /**< Native Android application, can be a null pointer, the given instance is just shared and not destroyed by this class */
00180         static PLCORE_API AAssetManager *g_pAAssetManager;      /**< Android asset manager, can be a null pointer, the given instance is just shared and not destroyed by this class */
00181         static PLCORE_API bool           g_bConsoleToKernelLog; /**< 'true' if console messages are also written into the Android in-kernel log buffer, else 'false', default is 'false' */
00182 
00183 
00184     //[-------------------------------------------------------]
00185     //[ Private data                                          ]
00186     //[-------------------------------------------------------]
00187     private:
00188         ConsoleAndroid m_cConsole;  /**< Console instance (messages will be written into the Android in-kernel log buffer) */
00189 
00190 
00191 };
00192 
00193 
00194 //[-------------------------------------------------------]
00195 //[ Namespace                                             ]
00196 //[-------------------------------------------------------]
00197 } // PLCore
00198 
00199 
00200 //[-------------------------------------------------------]
00201 //[ Implementation                                        ]
00202 //[-------------------------------------------------------]
00203 #include "PLCore/System/SystemAndroid.inl"
00204 
00205 
00206 #endif // __PLCORE_SYSTEM_ANDROID_H__


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