PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: Loader.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_LOADER_H__ 00024 #define __PLCORE_LOADER_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/String/String.h" 00032 #include "PLCore/Container/Array.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLCore { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Forward declarations ] 00043 //[-------------------------------------------------------] 00044 class Class; 00045 class Loadable; 00046 class LoaderImpl; 00047 class LoadableType; 00048 00049 00050 //[-------------------------------------------------------] 00051 //[ Classes ] 00052 //[-------------------------------------------------------] 00053 /** 00054 * @brief 00055 * Loader class 00056 * 00057 * @note 00058 * - Implementation of the proxy design pattern 00059 */ 00060 class Loader { 00061 00062 00063 //[-------------------------------------------------------] 00064 //[ Friends ] 00065 //[-------------------------------------------------------] 00066 friend class Loadable; 00067 friend class LoadableType; 00068 friend class LoadableManager; 00069 00070 00071 //[-------------------------------------------------------] 00072 //[ Public functions ] 00073 //[-------------------------------------------------------] 00074 public: 00075 /** 00076 * @brief 00077 * Loader implementation class 00078 * 00079 * @return 00080 * Loader implementation class 00081 */ 00082 inline const Class &GetClass() const; 00083 00084 /** 00085 * @brief 00086 * Returns the loader implementation 00087 * 00088 * @return 00089 * The loader implementation, a null pointer on error 00090 * 00091 * @note 00092 * - If required, this method creates an instance of the loader implementation class 00093 */ 00094 PLCORE_API LoaderImpl *GetImpl(); 00095 00096 /** 00097 * @brief 00098 * Returns the loadable type 00099 * 00100 * @return 00101 * The loadable type, a null pointer on (terrible) error 00102 */ 00103 inline LoadableType *GetType() const; 00104 00105 /** 00106 * @brief 00107 * Returns the name of the loadable type 00108 * 00109 * @return 00110 * The name of the loadable type 00111 */ 00112 PLCORE_API String GetTypeName() const; 00113 00114 /** 00115 * @brief 00116 * Returns the number of supported formats 00117 * 00118 * @return 00119 * The number of supported formats 00120 */ 00121 inline uint32 GetNumOfFormats(); 00122 00123 /** 00124 * @brief 00125 * Returns a supported format 00126 * 00127 * @param[in] nIndex 00128 * Format index 00129 * 00130 * @return 00131 * The requested supported format, empty string on error 00132 */ 00133 inline String GetFormat(uint32 nIndex); 00134 00135 /** 00136 * @brief 00137 * Checks if a format is supported in a list of extensions 00138 * 00139 * @param[in] sExtension 00140 * Extension of loadable 00141 * 00142 * @return 00143 * 'true' if the format is supported, else 'false' 00144 */ 00145 PLCORE_API bool IsFormatSupported(const String &sExtension); 00146 00147 /** 00148 * @brief 00149 * Returns the formats string 00150 * 00151 * @return 00152 * The formats string 00153 */ 00154 PLCORE_API String GetFormats() const; 00155 00156 /** 00157 * @brief 00158 * Returns the description string 00159 * 00160 * @return 00161 * The description string 00162 */ 00163 PLCORE_API String GetDescription() const; 00164 00165 /** 00166 * @brief 00167 * Returns the whether loading is supported 00168 * 00169 * @return 00170 * 'true' if loading is supported, else 'false' 00171 */ 00172 PLCORE_API bool CanLoad() const; 00173 00174 /** 00175 * @brief 00176 * Returns the whether saving is supported 00177 * 00178 * @return 00179 * 'true' if saving is supported, else 'false' 00180 */ 00181 PLCORE_API bool CanSave() const; 00182 00183 00184 //[-------------------------------------------------------] 00185 //[ Private functions ] 00186 //[-------------------------------------------------------] 00187 private: 00188 /** 00189 * @brief 00190 * Default constructor 00191 */ 00192 Loader(); 00193 00194 /** 00195 * @brief 00196 * Constructor 00197 * 00198 * @param[in] cClass 00199 * Loader implementation class, must be derived from "PLCore::LoaderImpl" 00200 */ 00201 Loader(const Class &cClass); 00202 00203 /** 00204 * @brief 00205 * Destructor 00206 */ 00207 ~Loader(); 00208 00209 /** 00210 * @brief 00211 * Copy operator 00212 * 00213 * @param[in] cSource 00214 * Source to copy from 00215 * 00216 * @return 00217 * Reference to this instance 00218 */ 00219 Loader &operator =(const Loader &cSource); 00220 00221 /** 00222 * @brief 00223 * Initializes the formats list 00224 * 00225 * @note 00226 * - If the list is already initialized, nothing happens 00227 */ 00228 PLCORE_API void InitFormatsList(); 00229 00230 00231 //[-------------------------------------------------------] 00232 //[ Private data ] 00233 //[-------------------------------------------------------] 00234 private: 00235 const Class *m_pClass; /**< Loader implementation class, must be derived from "PLCore::LoaderImpl", always valid! */ 00236 LoaderImpl *m_pLoaderImpl; /**< Loader implementation class instance, can be a null pointer */ 00237 LoadableType *m_pLoadableType; /**< Loadable type, can be a null pointer */ 00238 Array<String> m_lstFormats; /**< List of parsed formats */ 00239 00240 00241 }; 00242 00243 00244 //[-------------------------------------------------------] 00245 //[ Namespace ] 00246 //[-------------------------------------------------------] 00247 } // PLCore 00248 00249 00250 //[-------------------------------------------------------] 00251 //[ Implementation ] 00252 //[-------------------------------------------------------] 00253 #include "PLCore/Tools/Loader.inl" 00254 00255 00256 #endif // __PLCORE_LOADER_H__
|