add Callback API in ExporterProperties
parent
ce838dfafb
commit
578a7ac502
|
@ -580,10 +580,24 @@ ExportProperties::ExportProperties(const ExportProperties &other)
|
|||
: mIntProperties(other.mIntProperties)
|
||||
, mFloatProperties(other.mFloatProperties)
|
||||
, mStringProperties(other.mStringProperties)
|
||||
, mMatrixProperties(other.mMatrixProperties) {
|
||||
, mMatrixProperties(other.mMatrixProperties)
|
||||
//wangyi 0608
|
||||
, mCallbackProperties(other.mCallbackProperties){
|
||||
// empty
|
||||
}
|
||||
|
||||
//wangyi 0608
|
||||
bool ExportProperties::SetPropertyCallback(const char *szName, std::function<void *(void *)> &f) {
|
||||
return SetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, f);
|
||||
}
|
||||
std::function<void *(void *)> ExportProperties::GetPropertyCallback(const char *szName) const {
|
||||
return GetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, 0);
|
||||
}
|
||||
//wangyi 0608
|
||||
bool ExportProperties::HasPropertyCallback(const char *szName) const {
|
||||
return HasGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Set a configuration property
|
||||
bool ExportProperties::SetPropertyInteger(const char* szName, int iValue) {
|
||||
|
|
|
@ -54,6 +54,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "cexport.h"
|
||||
#include <map>
|
||||
//wangyi 0608
|
||||
#include <functional>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
@ -98,8 +100,7 @@ public:
|
|||
unsigned int mEnforcePP;
|
||||
|
||||
// Constructor to fill all entries
|
||||
ExportFormatEntry( const char* pId, const char* pDesc, const char* pExtension, fpExportFunc pFunction, unsigned int pEnforcePP = 0u)
|
||||
{
|
||||
ExportFormatEntry(const char *pId, const char *pDesc, const char *pExtension, fpExportFunc pFunction, unsigned int pEnforcePP = 0u) {
|
||||
mDescription.id = pId;
|
||||
mDescription.description = pDesc;
|
||||
mDescription.fileExtension = pExtension;
|
||||
|
@ -108,9 +109,8 @@ public:
|
|||
}
|
||||
|
||||
ExportFormatEntry() :
|
||||
mExportFunction()
|
||||
, mEnforcePP()
|
||||
{
|
||||
mExportFunction(),
|
||||
mEnforcePP() {
|
||||
mDescription.id = NULL;
|
||||
mDescription.description = NULL;
|
||||
mDescription.fileExtension = NULL;
|
||||
|
@ -332,6 +332,8 @@ public:
|
|||
typedef std::map<KeyType, ai_real> FloatPropertyMap;
|
||||
typedef std::map<KeyType, std::string> StringPropertyMap;
|
||||
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
|
||||
//wangyi 0608
|
||||
typedef std::map<KeyType, std::function<void *(void *)>> CallbackPropertyMap;
|
||||
|
||||
public:
|
||||
/** Standard constructor
|
||||
|
@ -391,6 +393,9 @@ public:
|
|||
*/
|
||||
bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue);
|
||||
|
||||
//wangyi 0608
|
||||
bool SetPropertyCallback(const char *szName, std::function<void *(void *)> &f);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a configuration property.
|
||||
* @param szName Name of the property. All supported properties
|
||||
|
@ -443,6 +448,9 @@ public:
|
|||
const aiMatrix4x4 GetPropertyMatrix(const char *szName,
|
||||
const aiMatrix4x4 &sErrorReturn = aiMatrix4x4()) const;
|
||||
|
||||
//wangyi 0608
|
||||
std::function<void *(void *)> GetPropertyCallback(const char* szName) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Determine a integer configuration property has been set.
|
||||
* @see HasPropertyInteger()
|
||||
|
@ -469,8 +477,10 @@ public:
|
|||
*/
|
||||
bool HasPropertyMatrix(const char *szName) const;
|
||||
|
||||
protected:
|
||||
//wangyi 0608
|
||||
bool HasPropertyCallback(const char *szName) const;
|
||||
|
||||
protected:
|
||||
/** List of integer properties */
|
||||
IntPropertyMap mIntProperties;
|
||||
|
||||
|
@ -482,22 +492,21 @@ protected:
|
|||
|
||||
/** List of Matrix properties */
|
||||
MatrixPropertyMap mMatrixProperties;
|
||||
|
||||
//wangyi 0608
|
||||
CallbackPropertyMap mCallbackProperties;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
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);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId,
|
||||
inline aiReturn Exporter ::Export(const aiScene *pScene, const std::string &pFormatId,
|
||||
const std::string &pPath, unsigned int pPreprocessing,
|
||||
const ExportProperties* pProperties)
|
||||
{
|
||||
const ExportProperties *pProperties) {
|
||||
return Export(pScene, pFormatId.c_str(), pPath.c_str(), pPreprocessing, pProperties);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue