+ add aiImporterDesc API to hold importer meta information.

- cleanup some Importer APIs: FindLoader -> GetImporter, add some utility APIs. Note that this is a breaking API change.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1232 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2012-04-18 23:07:52 +00:00
parent 5975f3eff2
commit e479355d0a
9 changed files with 1665 additions and 1486 deletions
+1
View File
@@ -136,6 +136,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/assimp/IOStream.hpp"
#include "../include/assimp/IOSystem.hpp"
#include "../include/assimp/scene.h"
#include "../include/assimp/importerdesc.h"
#include "../include/assimp/postprocess.h"
#include "../include/assimp/Importer.hpp"
#include "../include/assimp/Exporter.hpp"
+9 -1
View File
@@ -190,7 +190,15 @@ public:
protected:
// -------------------------------------------------------------------
/** Called by Importer::GetExtensionList() for each loaded importer.
/** Called by #Importer::GetImporterInfo to get a description of
* some loader features. Importer need not provide this structure,
* but it is highly recommended. */
virtual const aiImporterDesc* GetInfo() {
return NULL;
}
// -------------------------------------------------------------------
/** Called by #Importer::GetExtensionList for each loaded importer.
* Implementations are expected to insert() all file extensions
* handled by them into the extension set. A loader capable of
* reading certain files with the extension BLA would place the
+5 -5
View File
@@ -71,12 +71,12 @@ using namespace Assimp;
using namespace Assimp::Blender;
using namespace Assimp::Formatter;
static const aiLoaderDesc blenderDesc = {
static const aiImporterDesc blenderDesc = {
"Blender 3D Importer \nhttp://www.blender3d.org",
"Assimp Team",
"",
"",
aiLoaderFlags_SupportBinaryFlavour | aiLoaderFlags_Experimental,
"",
aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_Experimental,
0,
0,
2,
@@ -123,9 +123,9 @@ void BlenderImporter::GetExtensionList(std::set<std::string>& app)
// ------------------------------------------------------------------------------------------------
// Loader registry entry
const aiLoaderDesc& BlenderImporter::GetInfo () const
const aiImporterDesc* BlenderImporter::GetInfo () const
{
return blenderDesc;
return &blenderDesc;
}
// ------------------------------------------------------------------------------------------------
+1 -27
View File
@@ -85,32 +85,6 @@ namespace Assimp {
class BlenderModifier;
}
enum aiLoaderFlags
{
aiLoaderFlags_SupportAsciiFlavour = 0x1,
aiLoaderFlags_SupportBinaryFlavour = 0x2,
aiLoaderFlags_SupportCompressedFlavour = 0x4,
aiLoaderFlags_LimitedSupport = 0x8,
aiLoaderFlags_Experimental = 0x10,
aiLoaderFlags_Testing = 0x20,
aiLoaderFlags_Production = 0x40
};
struct aiLoaderDesc
{
const char* mName;
const char* mAuthor;
const char* mMaintainer;
const char* mComments;
unsigned int mFlags;
unsigned int mMinMajor;
unsigned int mMinMinor;
unsigned int mMaxMajor;
unsigned int mMaxMinor;
};
// -------------------------------------------------------------------------------------------
@@ -136,7 +110,7 @@ public:
protected:
// --------------------
const aiLoaderDesc& GetInfo () const;
const aiImporterDesc* GetInfo () const;
// --------------------
void GetExtensionList(std::set<std::string>& app);
+1
View File
@@ -46,6 +46,7 @@ SET( PUBLIC_HEADERS
${HEADER_PATH}/vector3.inl
${HEADER_PATH}/version.h
${HEADER_PATH}/cimport.h
${HEADER_PATH}/importerdesc.h
${HEADER_PATH}/Importer.hpp
${HEADER_PATH}/DefaultLogger.hpp
${HEADER_PATH}/ProgressHandler.hpp
+37 -5
View File
@@ -818,12 +818,44 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
// Helper function to check whether an extension is supported by ASSIMP
bool Importer::IsExtensionSupported(const char* szExtension) const
{
return NULL != FindLoader(szExtension);
return NULL != GetImporter(szExtension);
}
// ------------------------------------------------------------------------------------------------
size_t Importer::GetImporterCount() const
{
return pimpl->mImporter.size();
}
// ------------------------------------------------------------------------------------------------
const aiImporterDesc* Importer::GetImporterInfo(size_t index) const
{
if (index >= pimpl->mImporter.size()) {
return NULL;
}
return pimpl->mImporter[index]->GetInfo();
}
// ------------------------------------------------------------------------------------------------
BaseImporter* Importer::GetImporter (size_t index) const
{
if (index >= pimpl->mImporter.size()) {
return NULL;
}
return pimpl->mImporter[index];
}
// ------------------------------------------------------------------------------------------------
// Find a loader plugin for a given file extension
BaseImporter* Importer::FindLoader (const char* szExtension) const
BaseImporter* Importer::GetImporter (const char* szExtension) const
{
return GetImporter(GetImporterIndex(szExtension));
}
// ------------------------------------------------------------------------------------------------
// Find a loader plugin for a given file extension
size_t Importer::GetImporterIndex (const char* szExtension) const
{
ai_assert(szExtension);
ASSIMP_BEGIN_EXCEPTION_REGION();
@@ -844,12 +876,12 @@ BaseImporter* Importer::FindLoader (const char* szExtension) const
(*i)->GetExtensionList(str);
for (std::set<std::string>::const_iterator it = str.begin(); it != str.end(); ++it) {
if (ext == *it) {
return (*i);
return std::distance(static_cast< std::vector<BaseImporter*>::const_iterator >(pimpl->mImporter.begin()), i);
}
}
}
ASSIMP_END_EXCEPTION_REGION(BaseImporter*);
return NULL;
ASSIMP_END_EXCEPTION_REGION(size_t);
return static_cast<size_t>(-1);
}
// ------------------------------------------------------------------------------------------------