Browse Source

adapt c-api to get ImporterDesc for a given loader ( see https://github.com/assimp/assimp/issues/412 ).

Signed-off-by: Kim Kulling <[email protected]>
Kim Kulling 10 years ago
parent
commit
7a31a68cfc
5 changed files with 30 additions and 3 deletions
  1. 24 1
      code/Assimp.cpp
  2. 1 0
      code/BaseImporter.h
  3. 1 1
      include/assimp/cimport.h
  4. 2 0
      include/assimp/importerdesc.h
  5. 2 1
      test/CMakeLists.txt

+ 24 - 1
code/Assimp.cpp

@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "GenericProperty.h"
 #include "CInterfaceIOWrapper.h"
+#include "../include/assimp/importerdesc.h"
 #include "Importer.h"
 
 // ------------------------------------------------------------------------------------------------
@@ -84,7 +85,11 @@ namespace Assimp
 
 	/** Verbose logging active or not? */
 	static aiBool gVerboseLogging = false;
-}
+
+    /** will return all registered importers. */
+    void GetImporterInstanceList(std::vector< BaseImporter* >& out);
+
+} // namespace assimp
 
 
 #ifndef ASSIMP_BUILD_SINGLETHREADED
@@ -606,4 +611,22 @@ ASSIMP_API void aiIdentityMatrix4(
 	*mat = aiMatrix4x4();
 }
 
+// ------------------------------------------------------------------------------------------------
+ASSIMP_API C_STRUCT const aiImporterDesc* aiGetImporterDesc( const char *extension ) {
+    if( NULL == extension ) {
+        return NULL;
+    }
+    const aiImporterDesc *desc( NULL );
+    std::vector< BaseImporter* > out;
+    GetImporterInstanceList( out );
+    for( size_t i = 0; i < out.size(); ++i ) {
+        if( 0 == strncmp( out[ i ]->GetInfo()->mFileExtensions, extension, strlen( extension ) ) ) {
+            desc = out[ i ]->GetInfo();
+            break;
+        }
+    }
 
+    return desc;
+}
+
+// ------------------------------------------------------------------------------------------------

+ 1 - 0
code/BaseImporter.h

@@ -91,6 +91,7 @@ struct ScopeGuard
 
 private:
     // no copying allowed.
+    ScopeGuard();
     ScopeGuard( const ScopeGuard & );
     ScopeGuard &operator = ( const ScopeGuard & );
 

+ 1 - 1
include/assimp/cimport.h

@@ -247,7 +247,7 @@ ASSIMP_API C_STRUCT aiLogStream aiGetPredefinedLogStream(
  *  Attaching a log stream can slightly reduce Assimp's overall import
  *  performance. Multiple log-streams can be attached. 
  *  @param stream Describes the new log stream.
- *  @note To ensure proepr destruction of the logging system, you need to manually
+ *  @note To ensure proper destruction of the logging system, you need to manually
  *    call aiDetachLogStream() on every single log stream you attach. 
  *    Alternatively (for the lazy folks) #aiDetachAllLogStreams is provided.
  */

+ 2 - 0
include/assimp/importerdesc.h

@@ -133,4 +133,6 @@ struct aiImporterDesc
 	const char* mFileExtensions;
 };
 
+ASSIMP_API C_STRUCT const aiImporterDesc* aiGetImporterDesc( const char *extension );
+
 #endif 

+ 2 - 1
test/CMakeLists.txt

@@ -16,7 +16,8 @@ SOURCE_GROUP( unit FILES
 )
 
 SET( TEST_SRCS
-	unit/utFastAtof.cpp
+	unit/AssimpAPITest.cpp
+    unit/utFastAtof.cpp
 	unit/utFindDegenerates.cpp
 	unit/utFindInvalidData.cpp
 	unit/utFixInfacingNormals.cpp