PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: Module.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_MODULE_H__ 00024 #define __PLCORE_MODULE_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/String/String.h" 00032 #include "PLCore/Container/List.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLCore { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Forward declarations ] 00043 //[-------------------------------------------------------] 00044 class Class; 00045 class DynLib; 00046 00047 00048 //[-------------------------------------------------------] 00049 //[ Classes ] 00050 //[-------------------------------------------------------] 00051 /** 00052 * @brief 00053 * Description and interface for modules 00054 * 00055 * @remarks 00056 * A module is a unit like for example an executable or a shared library that contains RTTI content. 00057 * There can only be one RTTI module per executable or a shared library. A module can either be a 00058 * plugin or not. The term plugin means in this case that a module is not explicitly linked to the 00059 * executable or to a used shared library and therefore not loaded automatically by the operation 00060 * system on startup. 00061 */ 00062 class Module { 00063 00064 00065 //[-------------------------------------------------------] 00066 //[ Friends ] 00067 //[-------------------------------------------------------] 00068 friend class ClassDummy; 00069 friend class ClassManager; 00070 00071 00072 //[-------------------------------------------------------] 00073 //[ Public functions ] 00074 //[-------------------------------------------------------] 00075 public: 00076 /** 00077 * @brief 00078 * Get module ID 00079 * 00080 * @return 00081 * Module ID 00082 */ 00083 inline uint32 GetModuleID() const; 00084 00085 /** 00086 * @brief 00087 * Check if module is loaded as a plugin 00088 * 00089 * @return 00090 * 'true' if module is a plugin, else 'false' 00091 */ 00092 inline bool IsPlugin() const; 00093 00094 /** 00095 * @brief 00096 * Get dynamic library that contains the plugin 00097 * 00098 * @return 00099 * Pointer to dynamic library (can be a null pointer, if the module is not a plugin, do NOT destroy the returned instance!) 00100 * 00101 * @remarks 00102 * This function will only return a dynamic library, if the module is a plugin 00103 */ 00104 inline DynLib *GetDynLib() const; 00105 00106 /** 00107 * @brief 00108 * Get absolute filename of dynamic library or executable that contains the plugin 00109 * 00110 * @return 00111 * Absolute filename of dynamic library or executable that contains the plugin (native path style, can be empty in case it was impossible to determine the filename) 00112 */ 00113 inline String GetFilename() const; 00114 00115 /** 00116 * @brief 00117 * Get module name 00118 * 00119 * @return 00120 * Name 00121 */ 00122 inline String GetName() const; 00123 00124 /** 00125 * @brief 00126 * Get module vendor 00127 * 00128 * @return 00129 * Vendor name 00130 */ 00131 inline String GetVendor() const; 00132 00133 /** 00134 * @brief 00135 * Get module license 00136 * 00137 * @return 00138 * License 00139 */ 00140 inline String GetLicense() const; 00141 00142 /** 00143 * @brief 00144 * Get module description 00145 * 00146 * @return 00147 * Description 00148 */ 00149 inline String GetDescription() const; 00150 00151 /** 00152 * @brief 00153 * Get classes of module 00154 * 00155 * @return 00156 * List of classes 00157 * 00158 * @remarks 00159 * This method always returns all classes of a module. 00160 * If you want to search for classes with more specific search criteria, 00161 * have a look at ClassManager::GetClasses(). 00162 */ 00163 inline const List<const Class*> &GetClasses() const; 00164 00165 00166 //[-------------------------------------------------------] 00167 //[ Private functions ] 00168 //[-------------------------------------------------------] 00169 private: 00170 /** 00171 * @brief 00172 * Constructor 00173 * 00174 * @param[in] nModuleID 00175 * Module ID 00176 */ 00177 PLCORE_API Module(uint32 nModuleID); 00178 00179 /** 00180 * @brief 00181 * Destructor 00182 */ 00183 PLCORE_API ~Module(); 00184 00185 /** 00186 * @brief 00187 * Set module information 00188 * 00189 * @param[in] sName 00190 * Module name 00191 * @param[in] sVendor 00192 * Module vendor 00193 * @param[in] sLicense 00194 * Module license 00195 * @param[in] sDescription 00196 * Module description 00197 */ 00198 PLCORE_API void SetModuleInfo(const String &sName, const String &sVendor, const String &sLicense, const String &sDescription); 00199 00200 /** 00201 * @brief 00202 * Add class 00203 * 00204 * @param[in] pClass 00205 * Pointer to class (must be valid) 00206 */ 00207 inline void AddClass(const Class *pClass); 00208 00209 /** 00210 * @brief 00211 * Remove class 00212 * 00213 * @param[in] pClass 00214 * Pointer to class (must be valid) 00215 */ 00216 inline void RemoveClass(const Class *pClass); 00217 00218 00219 //[-------------------------------------------------------] 00220 //[ Private data ] 00221 //[-------------------------------------------------------] 00222 private: 00223 // Module information 00224 uint32 m_nModuleID; /**< Module ID */ 00225 bool m_bPlugin; /**< Is module a plugin? */ 00226 DynLib *m_pDynLib; /**< Plugin library (can be a null pointer, has the ownership over the dynamic library instance) */ 00227 String m_sFilename; /**< Absolute absolute filename of dynamic library or executable that contains the plugin (native path style, can be empty in case it was impossible to determine the filename) */ 00228 String m_sName; /**< Name of module */ 00229 String m_sVendor; /**< Vendor of module */ 00230 String m_sLicense; /**< License of module */ 00231 String m_sDescription; /**< Description of module */ 00232 // Classes 00233 List<const Class*> m_lstClasses; /**< List of classes */ 00234 00235 00236 }; 00237 00238 00239 //[-------------------------------------------------------] 00240 //[ Namespace ] 00241 //[-------------------------------------------------------] 00242 } // PLCore 00243 00244 00245 //[-------------------------------------------------------] 00246 //[ Implementation ] 00247 //[-------------------------------------------------------] 00248 #include "PLCore/Base/Module.inl" 00249 00250 00251 #endif // __PLCORE_MODULE_H__
|