Exporter: fix some review findings.

pull/1090/head
Kim Kulling 2016-11-30 17:17:07 +01:00
parent a46b481985
commit 2193a93875
1 changed files with 24 additions and 46 deletions

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2011, assimp team Copyright (c) 2006-2016, assimp team
All rights reserved. All rights reserved.
@ -51,17 +51,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "cexport.h" #include "cexport.h"
#include <map> #include <map>
namespace Assimp { namespace Assimp {
class ExporterPimpl;
class IOSystem; class ExporterPimpl;
class IOSystem;
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
/** CPP-API: The Exporter class forms an C++ interface to the export functionality /** CPP-API: The Exporter class forms an C++ interface to the export functionality
* of the Open Asset Import Library. Note that the export interface is available * of the Open Asset Import Library. Note that the export interface is available
* only if Assimp has been built with ASSIMP_BUILD_NO_EXPORT not defined. * only if Assimp has been built with ASSIMP_BUILD_NO_EXPORT not defined.
* *
* The interface is modelled after the importer interface and mostly * The interface is modeled after the importer interface and mostly
* symmetric. The same rules for threading etc. apply. * symmetric. The same rules for threading etc. apply.
* *
* In a nutshell, there are two export interfaces: #Export, which writes the * In a nutshell, there are two export interfaces: #Export, which writes the
@ -74,17 +74,10 @@ namespace Assimp {
* #ExportToBlob is especially useful if you intend to work * #ExportToBlob is especially useful if you intend to work
* with the data in-memory. * with the data in-memory.
*/ */
class ASSIMP_API ExportProperties; class ASSIMP_API ExportProperties;
class ASSIMP_API Exporter class ASSIMP_API Exporter {
// TODO: causes good ol' base class has no dll interface warning
//#ifdef __cplusplus
// : public boost::noncopyable
//#endif // __cplusplus
{
public: public:
/** Function pointer type of a Export worker function */ /** Function pointer type of a Export worker function */
typedef void (*fpExportFunc)(const char*, IOSystem*, const aiScene*, const ExportProperties*); typedef void (*fpExportFunc)(const char*, IOSystem*, const aiScene*, const ExportProperties*);
@ -97,7 +90,7 @@ public:
// Worker function to do the actual exporting // Worker function to do the actual exporting
fpExportFunc mExportFunction; fpExportFunc mExportFunction;
// Postprocessing steps to be executed PRIOR to invoking mExportFunction // Post-processing steps to be executed PRIOR to invoking mExportFunction
unsigned int mEnforcePP; unsigned int mEnforcePP;
// Constructor to fill all entries // Constructor to fill all entries
@ -122,14 +115,10 @@ public:
public: public:
Exporter(); Exporter();
~Exporter(); ~Exporter();
public: public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Supplies a custom IO handler to the exporter to use to open and /** Supplies a custom IO handler to the exporter to use to open and
* access files. * access files.
@ -163,8 +152,6 @@ public:
* @return true by default */ * @return true by default */
bool IsDefaultIOHandler() const; bool IsDefaultIOHandler() const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Exports the given scene to a chosen file format. Returns the exported /** Exports the given scene to a chosen file format. Returns the exported
* data as a binary blob which you can write into a file or something. * data as a binary blob which you can write into a file or something.
@ -184,8 +171,7 @@ public:
* @note Use aiCopyScene() to get a modifiable copy of a previously * @note Use aiCopyScene() to get a modifiable copy of a previously
* imported scene. */ * imported scene. */
const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL); const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
inline const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL); const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Convenience function to export directly to a file. Use /** Convenience function to export directly to a file. Use
@ -213,16 +199,15 @@ public:
* triangulate data so they would run the step even if it wasn't requested. * triangulate data so they would run the step even if it wasn't requested.
* *
* If assimp detects that the input scene was directly taken from the importer side of * If assimp detects that the input scene was directly taken from the importer side of
* the library (i.e. not copied using aiCopyScene and potetially modified afterwards), * the library (i.e. not copied using aiCopyScene and potentially modified afterwards),
* any postprocessing steps already applied to the scene will not be applied again, unless * any post-processing steps already applied to the scene will not be applied again, unless
* they show non-idempotent behaviour (#aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and * they show non-idempotent behavior (#aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and
* #aiProcess_FlipWindingOrder). * #aiProcess_FlipWindingOrder).
* @return AI_SUCCESS if everything was fine. * @return AI_SUCCESS if everything was fine.
* @note Use aiCopyScene() to get a modifiable copy of a previously * @note Use aiCopyScene() to get a modifiable copy of a previously
* imported scene.*/ * imported scene.*/
aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL); aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
inline aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL); aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Returns an error description of an error that occurred in #Export /** Returns an error description of an error that occurred in #Export
@ -236,30 +221,26 @@ public:
* following methods is called: #Export, #ExportToBlob, #FreeBlob */ * following methods is called: #Export, #ExportToBlob, #FreeBlob */
const char* GetErrorString() const; const char* GetErrorString() const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Return the blob obtained from the last call to #ExportToBlob */ /** Return the blob obtained from the last call to #ExportToBlob */
const aiExportDataBlob* GetBlob() const; const aiExportDataBlob* GetBlob() const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Orphan the blob from the last call to #ExportToBlob. This means /** Orphan the blob from the last call to #ExportToBlob. This means
* the caller takes ownership and is thus responsible for calling * the caller takes ownership and is thus responsible for calling
* the C API function #aiReleaseExportBlob to release it. */ * the C API function #aiReleaseExportBlob to release it. */
const aiExportDataBlob* GetOrphanedBlob() const; const aiExportDataBlob* GetOrphanedBlob() const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Frees the current blob. /** Frees the current blob.
* *
* The function does nothing if no blob has previously been * The function does nothing if no blob has previously been
* previously produced via #ExportToBlob. #FreeBlob is called * previously produced via #ExportToBlob. #FreeBlob is called
* automatically by the destructor. The only reason to call * automatically by the destructor. The only reason to call
* it manually would be to reclain as much storage as possible * it manually would be to reclaim as much storage as possible
* without giving up the #Exporter instance yet. */ * without giving up the #Exporter instance yet. */
void FreeBlob( ); void FreeBlob( );
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Returns the number of export file formats available in the current /** Returns the number of export file formats available in the current
* Assimp build. Use #Exporter::GetExportFormatDescription to * Assimp build. Use #Exporter::GetExportFormatDescription to
@ -270,13 +251,12 @@ public:
**/ **/
size_t GetExportFormatCount() const; size_t GetExportFormatCount() const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Returns a description of the nth export file format. Use # /** Returns a description of the nth export file format. Use #
* #Exporter::GetExportFormatCount to learn how many export * #Exporter::GetExportFormatCount to learn how many export
* formats are supported. * formats are supported.
* *
* The returned pointer is of static storage duration iff the * The returned pointer is of static storage duration if the
* pIndex pertains to a built-in exporter (i.e. one not registered * pIndex pertains to a built-in exporter (i.e. one not registered
* via #RegistrerExporter). It is restricted to the life-time of the * via #RegistrerExporter). It is restricted to the life-time of the
* #Exporter instance otherwise. * #Exporter instance otherwise.
@ -287,7 +267,6 @@ public:
* NULL if pIndex is out of range. */ * NULL if pIndex is out of range. */
const aiExportFormatDesc* GetExportFormatDescription( size_t pIndex ) const; const aiExportFormatDesc* GetExportFormatDescription( size_t pIndex ) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Register a custom exporter. Custom export formats are limited to /** Register a custom exporter. Custom export formats are limited to
* to the current #Exporter instance and do not affect the * to the current #Exporter instance and do not affect the
@ -301,11 +280,10 @@ public:
* occupied by another format. */ * occupied by another format. */
aiReturn RegisterExporter(const ExportFormatEntry& desc); aiReturn RegisterExporter(const ExportFormatEntry& desc);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Remove an export format previously registered with #RegisterExporter /** Remove an export format previously registered with #RegisterExporter
* from the #Exporter instance (this can also be used to drop * from the #Exporter instance (this can also be used to drop
* builtin exporters because those are implicitly registered * built-in exporters because those are implicitly registered
* using #RegisterExporter). * using #RegisterExporter).
* @param id Format id to be unregistered, this refers to the * @param id Format id to be unregistered, this refers to the
* 'id' field of #aiExportFormatDesc. * 'id' field of #aiExportFormatDesc.
@ -313,14 +291,11 @@ public:
* has no effect.*/ * has no effect.*/
void UnregisterExporter(const char* id); void UnregisterExporter(const char* id);
protected: protected:
// Just because we don't want you to know how we're hacking around. // Just because we don't want you to know how we're hacking around.
ExporterPimpl* pimpl; ExporterPimpl* pimpl;
}; };
class ASSIMP_API ExportProperties class ASSIMP_API ExportProperties
{ {
public: public:
@ -335,11 +310,9 @@ public:
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap; typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
public: public:
/** Standard constructor /** Standard constructor
* @see ExportProperties() * @see ExportProperties()
*/ */
ExportProperties(); ExportProperties();
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -487,19 +460,24 @@ protected:
MatrixPropertyMap mMatrixProperties; MatrixPropertyMap mMatrixProperties;
}; };
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
inline const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const std::string& pFormatId,unsigned int pPreprocessing, const ExportProperties* pProperties) inline
const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const std::string& pFormatId,
unsigned int pPreprocessing, const ExportProperties* pProperties)
{ {
return ExportToBlob(pScene,pFormatId.c_str(),pPreprocessing, pProperties); return ExportToBlob(pScene,pFormatId.c_str(),pPreprocessing, pProperties);
} }
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
inline aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing, const ExportProperties* pProperties) inline
aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId,
const std::string& pPath, unsigned int pPreprocessing,
const ExportProperties* pProperties)
{ {
return Export(pScene,pFormatId.c_str(),pPath.c_str(),pPreprocessing, pProperties); return Export(pScene,pFormatId.c_str(),pPath.c_str(),pPreprocessing, pProperties);
} }
} // namespace Assimp } // namespace Assimp
#endif // ASSIMP_BUILD_NO_EXPORT #endif // ASSIMP_BUILD_NO_EXPORT
#endif // AI_EXPORT_HPP_INC #endif // AI_EXPORT_HPP_INC