PixelLightAPI  .
Module.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Module.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_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 that contains the plugin
00109         *
00110         *  @return
00111         *    Absolute filename of dynamic library (can be empty, if the module is not a plugin)
00112         *
00113         *  @remarks
00114         *    This function will only return an absolute filename, if the module is a plugin
00115         */
00116         inline String GetFilename() const;
00117 
00118         /**
00119         *  @brief
00120         *    Get module name
00121         *
00122         *  @return
00123         *    Name
00124         */
00125         inline String GetName() const;
00126 
00127         /**
00128         *  @brief
00129         *    Get module vendor
00130         *
00131         *  @return
00132         *    Vendor name
00133         */
00134         inline String GetVendor() const;
00135 
00136         /**
00137         *  @brief
00138         *    Get module license
00139         *
00140         *  @return
00141         *    License
00142         */
00143         inline String GetLicense() const;
00144 
00145         /**
00146         *  @brief
00147         *    Get module description
00148         *
00149         *  @return
00150         *    Description
00151         */
00152         inline String GetDescription() const;
00153 
00154         /**
00155         *  @brief
00156         *    Get classes of module
00157         *
00158         *  @return
00159         *    List of classes
00160         *
00161         *  @remarks
00162         *    This method always returns all classes of a module.
00163         *    If you want to search for classes with more specific search criteria,
00164         *    have a look at ClassManager::GetClasses().
00165         */
00166         inline const List<const Class*> &GetClasses() const;
00167 
00168 
00169     //[-------------------------------------------------------]
00170     //[ Private functions                                     ]
00171     //[-------------------------------------------------------]
00172     private:
00173         /**
00174         *  @brief
00175         *    Constructor
00176         *
00177         *  @param[in] nModuleID
00178         *    Module ID
00179         */
00180         PLCORE_API Module(uint32 nModuleID);
00181 
00182         /**
00183         *  @brief
00184         *    Destructor
00185         */
00186         PLCORE_API ~Module();
00187 
00188         /**
00189         *  @brief
00190         *    Set module information
00191         *
00192         *  @param[in] sName
00193         *    Module name
00194         *  @param[in] sVendor
00195         *    Module vendor
00196         *  @param[in] sLicense
00197         *    Module license
00198         *  @param[in] sDescription
00199         *    Module description
00200         */
00201         PLCORE_API void SetModuleInfo(const String &sName, const String &sVendor, const String &sLicense, const String &sDescription);
00202 
00203         /**
00204         *  @brief
00205         *    Add class
00206         *
00207         *  @param[in] pClass
00208         *    Pointer to class (must be valid)
00209         */
00210         inline void AddClass(const Class *pClass);
00211 
00212         /**
00213         *  @brief
00214         *    Remove class
00215         *
00216         *  @param[in] pClass
00217         *    Pointer to class (must be valid)
00218         */
00219         inline void RemoveClass(const Class *pClass);
00220 
00221 
00222     //[-------------------------------------------------------]
00223     //[ Private data                                          ]
00224     //[-------------------------------------------------------]
00225     private:
00226         // Module information
00227         uint32             m_nModuleID;     /**< Module ID */
00228         bool               m_bPlugin;       /**< Is module a plugin? */
00229         DynLib            *m_pDynLib;       /**< Plugin library (can be a null pointer, has the ownership over the dynamic library instance) */
00230         String             m_sFilename;     /**< Absolute plugin filename (can be empty) */
00231         String             m_sName;         /**< Name of module */
00232         String             m_sVendor;       /**< Vendor of module */
00233         String             m_sLicense;      /**< License of module */
00234         String             m_sDescription;  /**< Description of module */
00235         // Classes
00236         List<const Class*> m_lstClasses;    /**< List of classes */
00237 
00238 
00239 };
00240 
00241 
00242 //[-------------------------------------------------------]
00243 //[ Namespace                                             ]
00244 //[-------------------------------------------------------]
00245 } // PLCore
00246 
00247 
00248 //[-------------------------------------------------------]
00249 //[ Implementation                                        ]
00250 //[-------------------------------------------------------]
00251 #include "PLCore/Base/Module.inl"
00252 
00253 
00254 #endif // __PLCORE_MODULE_H__


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