| 1 | /**************************************************************************************** |
| 2 | |
| 3 | Copyright (C) 2015 Autodesk, Inc. |
| 4 | All rights reserved. |
| 5 | |
| 6 | Use of this software is subject to the terms of the Autodesk license agreement |
| 7 | provided at the time of installation or download, or which otherwise accompanies |
| 8 | this software in either electronic or hard copy form. |
| 9 | |
| 10 | ****************************************************************************************/ |
| 11 | |
| 12 | //! \file fbxiopluginregistry.h |
| 13 | #ifndef _FBXSDK_FILEIO_IO_PLUGIN_REGISTRY_H_ |
| 14 | #define _FBXSDK_FILEIO_IO_PLUGIN_REGISTRY_H_ |
| 15 | |
| 16 | #include <fbxsdk/fbxsdk_def.h> |
| 17 | |
| 18 | #include <fbxsdk/fileio/fbxreader.h> |
| 19 | #include <fbxsdk/fileio/fbxwriter.h> |
| 20 | |
| 21 | #include <fbxsdk/fbxsdk_nsbegin.h> |
| 22 | |
| 23 | /** \brief This class serves as the registrar for file formats. |
| 24 | * A file format must be registered when it is used by the FBX SDK. |
| 25 | * |
| 26 | * This class also lets you create and read formats other than FBX SDK native formats. |
| 27 | * Users of FBX SDK can write their own plug-ins to read or write arbitrary file formats. |
| 28 | * Once their plug-ins are registered in this class, FBX SDK is able to read or write |
| 29 | * these file formats. |
| 30 | * |
| 31 | * Each FbxManager has a unique FbxIOPluginRegistry. To get an instance of this class: |
| 32 | * \code |
| 33 | * FbxIOPluginRegistry* registry = manager->GetIOPluginRegistry(); |
| 34 | * \endcode |
| 35 | * \see FbxManager::GetIOPluginRegistry() |
| 36 | */ |
| 37 | class FBXSDK_DLL FbxIOPluginRegistry |
| 38 | { |
| 39 | public: |
| 40 | |
| 41 | /** Constructor. |
| 42 | */ |
| 43 | FbxIOPluginRegistry(); |
| 44 | |
| 45 | /** Destructor. |
| 46 | */ |
| 47 | virtual ~FbxIOPluginRegistry(); |
| 48 | |
| 49 | #ifndef FBXSDK_ENV_WINSTORE |
| 50 | /** Registers a Reader from a plug-in path. |
| 51 | * \param pPluginPath The plug-in path. |
| 52 | * \param pFirstPluginID Contains the ID of the first plug-in found. |
| 53 | * \param pRegisteredCount Contains the number of registered Readers. |
| 54 | * \param pOverride Override any existing writer that is using the same extension. |
| 55 | */ |
| 56 | void RegisterReader(const char* pPluginPath, |
| 57 | int& pFirstPluginID, |
| 58 | int& pRegisteredCount, |
| 59 | bool pOverride = false); |
| 60 | #endif /* !FBXSDK_ENV_WINSTORE */ |
| 61 | |
| 62 | /** Registers a Reader. |
| 63 | * \param pCreateF The function that creates the Reader to be registered. |
| 64 | * \param pInfoF The function that provides information about the Reader file format, such as the file extension and description. |
| 65 | * \param pFirstPluginID Contains the ID of the first plug-in found. |
| 66 | * \param pRegisteredCount Contains the number of registered Readers. |
| 67 | * \param pIOSettingsFillerF The function that fills the IO settings for the Reader. |
| 68 | * \param pOverride Override any existing writer that is using the same extension. |
| 69 | */ |
| 70 | void RegisterReader(FbxReader::CreateFuncType pCreateF, |
| 71 | FbxReader::GetInfoFuncType pInfoF, |
| 72 | int& pFirstPluginID, |
| 73 | int& pRegisteredCount, |
| 74 | FbxReader::IOSettingsFillerFuncType pIOSettingsFillerF = NULL, |
| 75 | bool pOverride = false); |
| 76 | |
| 77 | #ifndef FBXSDK_ENV_WINSTORE |
| 78 | /** Registers a Writer from a plug-in path |
| 79 | * \param pPluginPath The plug-in path. |
| 80 | * \param pFirstPluginID Contains the ID of the first plug-in found. |
| 81 | * \param pRegisteredCount Contains the number of registered Writers. |
| 82 | * \param pOverride Override any existing writer that is using the same extension. |
| 83 | */ |
| 84 | void RegisterWriter(const char* pPluginPath, |
| 85 | int& pFirstPluginID, |
| 86 | int& pRegisteredCount, |
| 87 | bool pOverride = false); |
| 88 | #endif /* !FBXSDK_ENV_WINSTORE */ |
| 89 | |
| 90 | /** Registers a Writer. |
| 91 | * \param pCreateF The function that creates the Writer to be registered. |
| 92 | * \param pInfoF The function that provides information about the Writer file format, such as the file extension, description and version. |
| 93 | * \param pFirstPluginID Contains the ID of the first plug-in found. |
| 94 | * \param pRegisteredCount Contains the number of registered Writers. |
| 95 | * \param pIOSettingsFillerF The function that fills the IO settings for the Writer. |
| 96 | * \param pOverride Override any existing writer that is using the same extension. |
| 97 | */ |
| 98 | void RegisterWriter(FbxWriter::CreateFuncType pCreateF, |
| 99 | FbxWriter::GetInfoFuncType pInfoF, |
| 100 | int& pFirstPluginID, |
| 101 | int& pRegisteredCount, |
| 102 | FbxWriter::IOSettingsFillerFuncType pIOSettingsFillerF = NULL, |
| 103 | bool pOverride = false); |
| 104 | |
| 105 | /** Creates a Reader. |
| 106 | * \param pManager The SDK Manager where the Reader is created. |
| 107 | * \param pImporter The importer that holds the created Reader. |
| 108 | * \param pPluginID The Reader ID. |
| 109 | */ |
| 110 | FbxReader* CreateReader(FbxManager& pManager, |
| 111 | FbxImporter& pImporter, |
| 112 | int pPluginID) const; |
| 113 | |
| 114 | /** Creates a Writer. |
| 115 | * \param pManager The SDK Manager where the Writer is created. |
| 116 | * \param pExporter The exporter that holds the created Writer. |
| 117 | * \param pPluginID The Writer ID. |
| 118 | */ |
| 119 | FbxWriter* CreateWriter(FbxManager& pManager, |
| 120 | FbxExporter& pExporter, |
| 121 | int pPluginID) const; |
| 122 | |
| 123 | /** Searches for the Reader ID by the file extension. |
| 124 | * \param pExt The file extension. |
| 125 | * \return The Reader ID if found, if not found, returns -1 |
| 126 | */ |
| 127 | int FindReaderIDByExtension(const char* pExt) const; |
| 128 | |
| 129 | /** Searches for the Writer ID by the file extension. |
| 130 | * \param pExt The file extension. |
| 131 | * \return The Writer ID if found, if not found, returns -1 |
| 132 | */ |
| 133 | int FindWriterIDByExtension(const char* pExt) const; |
| 134 | |
| 135 | /** Searches for the Reader ID by the file format description. |
| 136 | * \param pDesc The file format description. |
| 137 | * \return The Reader ID if found, if not found, returns -1 |
| 138 | */ |
| 139 | int FindReaderIDByDescription(const char* pDesc) const; |
| 140 | |
| 141 | /** Searches for the Writer ID by the file format description. |
| 142 | * \param pDesc The file format description. |
| 143 | * \return The Writer ID if found, if not found, returns -1. |
| 144 | */ |
| 145 | int FindWriterIDByDescription(const char* pDesc) const; |
| 146 | |
| 147 | /** Verifies if the file format of the Reader is FBX. |
| 148 | * \param pFileFormat The file format identifier. |
| 149 | * \return \c True if the file format of the Reader is FBX, return \c false otherwise.. |
| 150 | */ |
| 151 | bool ReaderIsFBX(int pFileFormat) const; |
| 152 | |
| 153 | /** Verifies if the file format of the Writer is FBX. |
| 154 | * \param pFileFormat The file format identifier. |
| 155 | * \return \c True if the file format of the Writer is FBX, return \c false otherwise. |
| 156 | */ |
| 157 | bool WriterIsFBX(int pFileFormat) const; |
| 158 | |
| 159 | /** Verifies if the file format of the Reader is genuine (internal). |
| 160 | * \param pFileFormat The file format identifier. |
| 161 | * \return \c True if the file format of the Reader is FBX, DXF, 3DS, OBJ and DAE, return \c false otherwise. |
| 162 | */ |
| 163 | bool ReaderIsGenuine(int pFileFormat) const; |
| 164 | |
| 165 | /** Verifies if the file format of the Writer is genuine (internal). |
| 166 | * \param pFileFormat The file format identifier. |
| 167 | * \return \c True if the file format of the Writer is FBX, DXF, 3DS, OBJ and DAE, return \c false otherwise. |
| 168 | */ |
| 169 | bool WriterIsGenuine(int pFileFormat) const; |
| 170 | |
| 171 | /** Returns the number of file formats that can be imported. |
| 172 | * \return The number of importable formats. |
| 173 | */ |
| 174 | int GetReaderFormatCount() const; |
| 175 | |
| 176 | /** Returns the number of file formats that can be exported. |
| 177 | * \return The number of exportable formats. |
| 178 | * \remarks Multiple identifiers for the same format count as |
| 179 | * different file formats. For example, eFBX_BINARY, eFBX_ASCII and eFBX_ENCRYPTED |
| 180 | * are counted as three separate file formats. |
| 181 | */ |
| 182 | int GetWriterFormatCount() const; |
| 183 | |
| 184 | /** Returns the description of an importable file format. |
| 185 | * \param pFileFormat The file format identifier. |
| 186 | * \return A pointer to the character representation of the description. |
| 187 | */ |
| 188 | const char* GetReaderFormatDescription(int pFileFormat) const; |
| 189 | |
| 190 | /** Returns the description of an exportable file format. |
| 191 | * \param pFileFormat The file format identifier. |
| 192 | * \return A pointer to the character representation of the description. |
| 193 | */ |
| 194 | const char* GetWriterFormatDescription(int pFileFormat) const; |
| 195 | |
| 196 | /** Returns an importable file format's file extension. |
| 197 | * \param pFileFormat The file format identifier. |
| 198 | * \return A pointer to the character representation of the file extension. |
| 199 | */ |
| 200 | const char* GetReaderFormatExtension(int pFileFormat) const; |
| 201 | |
| 202 | /** Returns an exportable file format's file extension. |
| 203 | * \param pFileFormat The file format identifier. |
| 204 | * \return A pointer to the character representation of the file extension. |
| 205 | */ |
| 206 | const char* GetWriterFormatExtension(int pFileFormat) const; |
| 207 | |
| 208 | /** Returns a list of the writable file format versions. |
| 209 | * \param pFileFormat The file format identifier. |
| 210 | * \return A pointer to a list of user-readable strings that represent the versions. |
| 211 | */ |
| 212 | char const* const* GetWritableVersions(int pFileFormat) const; |
| 213 | |
| 214 | /** Detects the import (reader) file format specified for the file. |
| 215 | * \param pFileName The file whose file format is to be determined. |
| 216 | * \param pFileFormat It equals the file format identifier if this function returns \c true. If this function returns \c false, it is unmodified. |
| 217 | * \return \c True if the file has been determined successfully, |
| 218 | * returns \c false otherwise. |
| 219 | * \remarks This function attempts to detect the specified file's file format based on the file extension and, |
| 220 | * in some cases, its content. This function may not be able to determine all file formats. |
| 221 | * Use this function as a helper before calling \c SetFileFormat(). |
| 222 | * \note The file must be unlocked (already open) for this function to succeed. |
| 223 | */ |
| 224 | bool DetectReaderFileFormat(const char* pFileName, int& pFileFormat) const; |
| 225 | |
| 226 | /** Detects the export (writer) file format specified for the file. |
| 227 | * \param pFileName The file whose file format is to be determined. |
| 228 | * \param pFileFormat It equals the file format identifier if this function returns \c true. If this function returns \c false, it is unmodified. |
| 229 | * \return \c True if the file has been determined successfully, |
| 230 | * returns \c false otherwise. |
| 231 | * \remarks This function attempts to detect the specified file's file format based on the file extension and, |
| 232 | * in some cases, its content. This function may not be able to determine all file formats. |
| 233 | * Use this function as a helper before calling \c SetFileFormat(). |
| 234 | * \note The file must be unlocked (already open) for this function to succeed. |
| 235 | */ |
| 236 | bool DetectWriterFileFormat(const char* pFileName, int& pFileFormat) const; |
| 237 | |
| 238 | /** Returns the file format of the native Reader. |
| 239 | * \return The ID of the native Reader's file format. |
| 240 | */ |
| 241 | int GetNativeReaderFormat(); |
| 242 | |
| 243 | /** Returns the file format of the native Writer. |
| 244 | * \return The ID of the native Writer's file format. |
| 245 | */ |
| 246 | int GetNativeWriterFormat(); |
| 247 | |
| 248 | /** Fills the IO Settings for all registered readers. |
| 249 | * \param pIOS The IO settings to be filled. |
| 250 | */ |
| 251 | void FillIOSettingsForReadersRegistered(FbxIOSettings & pIOS); |
| 252 | |
| 253 | /** Fills the IO Settings for all registered writers. |
| 254 | * \param pIOS The IO settings to be filled. |
| 255 | */ |
| 256 | void FillIOSettingsForWritersRegistered(FbxIOSettings & pIOS); |
| 257 | |
| 258 | |
| 259 | /***************************************************************************************************************************** |
| 260 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
| 261 | *****************************************************************************************************************************/ |
| 262 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 263 | private: |
| 264 | void RegisterInternalIOPlugins(); |
| 265 | |
| 266 | struct ReaderPluginEntry |
| 267 | { |
| 268 | ReaderPluginEntry(const char* pExtension, const char* pDescription, FbxReader::CreateFuncType pCreatorFunction, int pBaseID, |
| 269 | FbxReader::IOSettingsFillerFuncType pIOSettingsFillerFunction=NULL); |
| 270 | |
| 271 | const char* mExtension; |
| 272 | const char* mDescription; |
| 273 | FbxReader::CreateFuncType mCreatorFunction; |
| 274 | FbxReader::IOSettingsFillerFuncType mIOSettingsFillerFunction; |
| 275 | int mBaseID; |
| 276 | bool mIsFBX; |
| 277 | bool mIsInternalPlugin; |
| 278 | }; |
| 279 | |
| 280 | struct WriterPluginEntry |
| 281 | { |
| 282 | WriterPluginEntry(const char* pExtension, const char* pDescription, char const* const* pVersions, FbxWriter::CreateFuncType pCreatorFunction, int pBaseID, |
| 283 | FbxWriter::IOSettingsFillerFuncType pIOSettingsFillerFunction=NULL); |
| 284 | |
| 285 | const char* mExtension; |
| 286 | const char* mDescription; |
| 287 | char const* const* mVersions; |
| 288 | FbxWriter::CreateFuncType mCreatorFunction; |
| 289 | FbxWriter::IOSettingsFillerFuncType mIOSettingsFillerFunction; |
| 290 | int mBaseID; |
| 291 | bool mIsFBX; |
| 292 | bool mIsInternalPlugin; |
| 293 | }; |
| 294 | |
| 295 | FbxArray<ReaderPluginEntry*> mReaders; |
| 296 | FbxArray<WriterPluginEntry*> mWriters; |
| 297 | int mNativeReaderFormat; |
| 298 | int mNativeWriterFormat; |
| 299 | bool mInternalPluginMode; |
| 300 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
| 301 | }; |
| 302 | |
| 303 | #include <fbxsdk/fbxsdk_nsend.h> |
| 304 | |
| 305 | #endif /* _FBXSDK_FILEIO_IO_PLUGIN_REGISTRY_H_ */ |
| 306 | |