- Main Page
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# fbxnew.h

Go to the documentation of this file.

    00001 /****************************************************************************************
    00002
    00003    Copyright (C) 2012 Autodesk, Inc.
    00004    All rights reserved.
    00005
    00006    Use of this software is subject to the terms of the Autodesk license agreement
    00007    provided at the time of installation or download, or which otherwise accompanies
    00008    this software in either electronic or hard copy form.
    00009
    00010 ****************************************************************************************/
    00011
    00020 #ifndef _FBXSDK_CORE_ARCH_NEW_H_
    00021 #define _FBXSDK_CORE_ARCH_NEW_H_
    00022
    00023 #include <fbxsdk/fbxsdk_def.h>
    00024
    00025 #include <new>
    00026
    00027 #if defined(FBXSDK_COMPILER_MSC)
    00028     #pragma warning(push)
    00029     #pragma warning(disable : 4345) //warning C4345: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
    00030 #endif
    00031
    00032 #include <fbxsdk/fbxsdk_nsbegin.h>
    00033
    00034 //Type traits for primitive types
    00035 template<typename T> struct FbxSimpleType { enum {value = 0}; };
    00036 template<typename T> struct FbxSimpleType<T*> { enum {value = 1}; };
    00037 template<typename T> struct FbxSimpleType<const T> { enum {value = FbxSimpleType<T>::value}; };
    00038 template<typename T, size_t n> struct FbxSimpleType<T[n]> { enum {value = FbxSimpleType<T>::value}; };
    00039
    00040 #define FBXSDK_DEFINE_SIMPLE_TYPE(T) template<> struct FbxSimpleType<T>{ union {T t;} catcherr; enum {value = 1};}
    00041
    00042 FBXSDK_DEFINE_SIMPLE_TYPE(bool);
    00043 FBXSDK_DEFINE_SIMPLE_TYPE(char);
    00044 FBXSDK_DEFINE_SIMPLE_TYPE(unsigned char);
    00045 FBXSDK_DEFINE_SIMPLE_TYPE(short);
    00046 FBXSDK_DEFINE_SIMPLE_TYPE(unsigned short);
    00047 FBXSDK_DEFINE_SIMPLE_TYPE(int);
    00048 FBXSDK_DEFINE_SIMPLE_TYPE(unsigned int);
    00049 FBXSDK_DEFINE_SIMPLE_TYPE(long);
    00050 FBXSDK_DEFINE_SIMPLE_TYPE(unsigned long);
    00051 FBXSDK_DEFINE_SIMPLE_TYPE(float);
    00052 FBXSDK_DEFINE_SIMPLE_TYPE(double);
    00053 FBXSDK_DEFINE_SIMPLE_TYPE(long double);
    00054 FBXSDK_DEFINE_SIMPLE_TYPE(long long);
    00055 FBXSDK_DEFINE_SIMPLE_TYPE(unsigned long long);
    00056
    00057 #define FBXSDK_IS_SIMPLE_TYPE(T) ((bool)FbxSimpleType<T>::value)
    00058
    00059 template<typename T> T* FbxNew()
    00060 {
    00061     T* p = (T*)FbxMalloc(sizeof(T));
    00062     return new(p)T();
    00063 }
    00064
    00065 template<typename T, typename T1> T* FbxNew(T1& p1)
    00066 {
    00067     T* p = (T*)FbxMalloc(sizeof(T));
    00068     return new(p)T(p1);
    00069 }
    00070
    00071 template<typename T, typename T1> T* FbxNew(const T1& p1)
    00072 {
    00073     T* p = (T*)FbxMalloc(sizeof(T));
    00074     return new(p)T(p1);
    00075 }
    00076
    00077 template<typename T, typename T1, typename T2> T* FbxNew(T1& p1, T2& p2)
    00078 {
    00079     T* p = (T*)FbxMalloc(sizeof(T));
    00080     return new(p)T(p1, p2);
    00081 }
    00082
    00083 template<typename T, typename T1, typename T2> T* FbxNew(T1& p1, const T2& p2)
    00084 {
    00085     T* p = (T*)FbxMalloc(sizeof(T));
    00086     return new(p)T(p1, p2);
    00087 }
    00088
    00089 template<typename T, typename T1, typename T2> T* FbxNew(const T1& p1, T2& p2)
    00090 {
    00091     T* p = (T*)FbxMalloc(sizeof(T));
    00092     return new(p)T(p1, p2);
    00093 }
    00094
    00095 template<typename T, typename T1, typename T2> T* FbxNew(const T1& p1, const T2& p2)
    00096 {
    00097     T* p = (T*)FbxMalloc(sizeof(T));
    00098     return new(p)T(p1, p2);
    00099 }
    00100
    00101 template<typename T, typename T1, typename T2, typename T3> T* FbxNew(T1& p1, T2& p2, T3& p3)
    00102 {
    00103     T* p = (T*)FbxMalloc(sizeof(T));
    00104     return new(p)T(p1, p2, p3);
    00105 }
    00106
    00107 template<typename T, typename T1, typename T2, typename T3> T* FbxNew(T1& p1, T2& p2, const T3& p3)
    00108 {
    00109     T* p = (T*)FbxMalloc(sizeof(T));
    00110     return new(p)T(p1, p2, p3);
    00111 }
    00112
    00113 template<typename T, typename T1, typename T2, typename T3> T* FbxNew(T1& p1, const T2& p2, T3& p3)
    00114 {
    00115     T* p = (T*)FbxMalloc(sizeof(T));
    00116     return new(p)T(p1, p2, p3);
    00117 }
    00118
    00119 template<typename T, typename T1, typename T2, typename T3> T* FbxNew(T1& p1, const T2& p2, const T3& p3)
    00120 {
    00121     T* p = (T*)FbxMalloc(sizeof(T));
    00122     return new(p)T(p1, p2, p3);
    00123 }
    00124
    00125 template<typename T, typename T1, typename T2, typename T3> T* FbxNew(const T1& p1, T2& p2, T3& p3)
    00126 {
    00127     T* p = (T*)FbxMalloc(sizeof(T));
    00128     return new(p)T(p1, p2, p3);
    00129 }
    00130
    00131 template<typename T, typename T1, typename T2, typename T3> T* FbxNew(const T1& p1, T2& p2, const T3& p3)
    00132 {
    00133     T* p = (T*)FbxMalloc(sizeof(T));
    00134     return new(p)T(p1, p2, p3);
    00135 }
    00136
    00137 template<typename T, typename T1, typename T2, typename T3> T* FbxNew(const T1& p1, const T2& p2, T3& p3)
    00138 {
    00139     T* p = (T*)FbxMalloc(sizeof(T));
    00140     return new(p)T(p1, p2, p3);
    00141 }
    00142
    00143 template<typename T, typename T1, typename T2, typename T3> T* FbxNew(const T1& p1, const T2& p2, const T3& p3)
    00144 {
    00145     T* p = (T*)FbxMalloc(sizeof(T));
    00146     return new(p)T(p1, p2, p3);
    00147 }
    00148
    00149 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(T1& p1, T2& p2, T3& p3, T4& p4)
    00150 {
    00151     T* p = (T*)FbxMalloc(sizeof(T));
    00152     return new(p)T(p1, p2, p3, p4);
    00153 }
    00154
    00155 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(T1& p1, T2& p2, T3& p3, const T4& p4)
    00156 {
    00157     T* p = (T*)FbxMalloc(sizeof(T));
    00158     return new(p)T(p1, p2, p3, p4);
    00159 }
    00160
    00161 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(T1& p1, T2& p2, const T3& p3, T4& p4)
    00162 {
    00163     T* p = (T*)FbxMalloc(sizeof(T));
    00164     return new(p)T(p1, p2, p3, p4);
    00165 }
    00166
    00167 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(T1& p1, T2& p2, const T3& p3, const T4& p4)
    00168 {
    00169     T* p = (T*)FbxMalloc(sizeof(T));
    00170     return new(p)T(p1, p2, p3, p4);
    00171 }
    00172
    00173 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(T1& p1, const T2& p2, T3& p3, T4& p4)
    00174 {
    00175     T* p = (T*)FbxMalloc(sizeof(T));
    00176     return new(p)T(p1, p2, p3, p4);
    00177 }
    00178
    00179 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(T1& p1, const T2& p2, T3& p3, const T4& p4)
    00180 {
    00181     T* p = (T*)FbxMalloc(sizeof(T));
    00182     return new(p)T(p1, p2, p3, p4);
    00183 }
    00184
    00185 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(T1& p1, const T2& p2, const T3& p3, T4& p4)
    00186 {
    00187     T* p = (T*)FbxMalloc(sizeof(T));
    00188     return new(p)T(p1, p2, p3, p4);
    00189 }
    00190
    00191 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(T1& p1, const T2& p2, const T3& p3, const T4& p4)
    00192 {
    00193     T* p = (T*)FbxMalloc(sizeof(T));
    00194     return new(p)T(p1, p2, p3, p4);
    00195 }
    00196
    00197 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(const T1& p1, T2& p2, T3& p3, T4& p4)
    00198 {
    00199     T* p = (T*)FbxMalloc(sizeof(T));
    00200     return new(p)T(p1, p2, p3, p4);
    00201 }
    00202
    00203 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(const T1& p1, T2& p2, T3& p3, const T4& p4)
    00204 {
    00205     T* p = (T*)FbxMalloc(sizeof(T));
    00206     return new(p)T(p1, p2, p3, p4);
    00207 }
    00208
    00209 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(const T1& p1, T2& p2, const T3& p3, T4& p4)
    00210 {
    00211     T* p = (T*)FbxMalloc(sizeof(T));
    00212     return new(p)T(p1, p2, p3, p4);
    00213 }
    00214
    00215 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(const T1& p1, T2& p2, const T3& p3, const T4& p4)
    00216 {
    00217     T* p = (T*)FbxMalloc(sizeof(T));
    00218     return new(p)T(p1, p2, p3, p4);
    00219 }
    00220
    00221 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(const T1& p1, const T2& p2, T3& p3, T4& p4)
    00222 {
    00223     T* p = (T*)FbxMalloc(sizeof(T));
    00224     return new(p)T(p1, p2, p3, p4);
    00225 }
    00226
    00227 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(const T1& p1, const T2& p2, T3& p3, const T4& p4)
    00228 {
    00229     T* p = (T*)FbxMalloc(sizeof(T));
    00230     return new(p)T(p1, p2, p3, p4);
    00231 }
    00232
    00233 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(const T1& p1, const T2& p2, const T3& p3, T4& p4)
    00234 {
    00235     T* p = (T*)FbxMalloc(sizeof(T));
    00236     return new(p)T(p1, p2, p3, p4);
    00237 }
    00238
    00239 template<typename T, typename T1, typename T2, typename T3, typename T4> T* FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4)
    00240 {
    00241     T* p = (T*)FbxMalloc(sizeof(T));
    00242     return new(p)T(p1, p2, p3, p4);
    00243 }
    00244
    00245 template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5> T* FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5)
    00246 {
    00247     T* p = (T*)FbxMalloc(sizeof(T));
    00248     return new(p)T(p1,p2,p3,p4,p5);
    00249 }
    00250
    00251 template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> T* FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const T6& p6)
    00252 {
    00253     T* p = (T*)FbxMalloc(sizeof(T));
    00254     return new(p)T(p1,p2,p3,p4,p5,p6);
    00255 }
    00256
    00257 template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> T* FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const T6& p6, const T7& p7)
    00258 {
    00259     T* p = (T*)FbxMalloc(sizeof(T));
    00260     return new(p)T(p1,p2,p3,p4,p5,p6,p7);
    00261 }
    00262
    00263 template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> T* FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const T6& p6, const T7& p7, const T8& p8)
    00264 {
    00265     T* p = (T*)FbxMalloc(sizeof(T));
    00266     return new(p)T(p1,p2,p3,p4,p5,p6,p7,p8);
    00267 }
    00268
    00269 template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> T* FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const T6& p6, const T7& p7, const T8& p8, const T9& p9)
    00270 {
    00271     T* p = (T*)FbxMalloc(sizeof(T));
    00272     return new(p)T(p1,p2,p3,p4,p5,p6,p7,p8,p9);
    00273 }
    00274
    00275 template<typename T> void FbxDelete(T* p)
    00276 {
    00277     if( p )
    00278     {
    00279         ((T*)p)->~T();
    00280         FbxFree(p);
    00281     }
    00282 }
    00283
    00284 template<typename T> void FbxDelete(const T* p)
    00285 {
    00286     if( p )
    00287     {
    00288         ((T*)p)->~T();
    00289         FbxFree(const_cast<T*>(p));
    00290     }
    00291 }
    00292
    00293 template<typename T> T* FbxNewArray(int n)
    00294 {
    00295     if( FBXSDK_IS_SIMPLE_TYPE(T) )
    00296     {
    00297         return (T*)FbxMalloc(sizeof(T)*n);
    00298     }
    00299     else
    00300     {
    00301         void *pTmp = FbxMalloc(sizeof(T)*n+sizeof(int));
    00302         T* p = (T*)((int*)pTmp+1);
    00303         *((int*)pTmp) = n;
    00304         for(int i=0;i<n;++i)
    00305             new((T*)p+i)T;
    00306         return p;
    00307     }
    00308 }
    00309
    00310 template<typename T> void FbxDeleteArray(T* p)
    00311 {
    00312     if( p )
    00313     {
    00314         if( !FBXSDK_IS_SIMPLE_TYPE(T) )
    00315         {
    00316             for(int i=0;i<((int*)p)[-1];++i)
    00317                 ((T*)p)[i].~T();
    00318             FbxFree((int*)p-1);
    00319         }
    00320         else
    00321         {
    00322             FbxFree((void*)p);
    00323         }
    00324     }
    00325 }
    00326
    00327 #define FBXSDK_FRIEND_NEW()\
    00328     template<typename T>\
    00329     friend T* FBXSDK_NAMESPACE::FbxNew();\
    00330     template<typename T, typename T1>\
    00331     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1);\
    00332     template<typename T, typename T1>\
    00333     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1);\
    00334     template<typename T, typename T1, typename T2>\
    00335     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, T2& p2);\
    00336     template<typename T, typename T1, typename T2>\
    00337     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, const T2& p2);\
    00338     template<typename T, typename T1, typename T2>\
    00339     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, T2& p2);\
    00340     template<typename T, typename T1, typename T2>\
    00341     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2);\
    00342     template<typename T, typename T1, typename T2, typename T3>\
    00343     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, T2& p2, T3& p3);\
    00344     template<typename T, typename T1, typename T2, typename T3>\
    00345     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, T2& p2, const T3& p3);\
    00346     template<typename T, typename T1, typename T2, typename T3>\
    00347     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, const T2& p2, T3& p3);\
    00348     template<typename T, typename T1, typename T2, typename T3>\
    00349     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, const T2& p2, const T3& p3);\
    00350     template<typename T, typename T1, typename T2, typename T3>\
    00351     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, T2& p2, T3& p3);\
    00352     template<typename T, typename T1, typename T2, typename T3>\
    00353     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, T2& p2, const T3& p3);\
    00354     template<typename T, typename T1, typename T2, typename T3>\
    00355     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, T3& p3);\
    00356     template<typename T, typename T1, typename T2, typename T3>\
    00357     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, const T3& p3);\
    00358     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00359     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, T2& p2, T3& p3, T4& p4);\
    00360     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00361     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, T2& p2, T3& p3, const T4& p4);\
    00362     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00363     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, T2& p2, const T3& p3, T4& p4);\
    00364     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00365     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, T2& p2, const T3& p3, const T4& p4);\
    00366     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00367     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, const T2& p2, T3& p3, T4& p4);\
    00368     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00369     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, const T2& p2, T3& p3, const T4& p4);\
    00370     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00371     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, const T2& p2, const T3& p3, T4& p4);\
    00372     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00373     friend T* FBXSDK_NAMESPACE::FbxNew(T1& p1, const T2& p2, const T3& p3, const T4& p4);\
    00374     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00375     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, T2& p2, T3& p3, T4& p4);\
    00376     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00377     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, T2& p2, T3& p3, const T4& p4);\
    00378     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00379     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, T2& p2, const T3& p3, T4& p4);\
    00380     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00381     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, T2& p2, const T3& p3, const T4& p4);\
    00382     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00383     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, T3& p3, T4& p4);\
    00384     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00385     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, T3& p3, const T4& p4);\
    00386     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00387     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, const T3& p3, T4& p4);\
    00388     template<typename T, typename T1, typename T2, typename T3, typename T4>\
    00389     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4);\
    00390     template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5>\
    00391     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5);\
    00392     template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>\
    00393     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const T6& p6);\
    00394     template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>\
    00395     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const T6& p6, const T7& p7);\
    00396     template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>\
    00397     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const T6& p6, const T7& p7, const T8& p8);\
    00398     template<typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>\
    00399     friend T* FBXSDK_NAMESPACE::FbxNew(const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const T6& p6, const T7& p7, const T8& p8, const T9& p9);\
    00400     template<typename T>\
    00401     friend void FBXSDK_NAMESPACE::FbxDelete(T* p);\
    00402     template<typename T>\
    00403     friend void FBXSDK_NAMESPACE::FbxDelete(const T* p);\
    00404     template<typename T>\
    00405     friend T* FBXSDK_NAMESPACE::FbxNewArray(int n);\
    00406     template<typename T>\
    00407     friend void FBXSDK_NAMESPACE::FbxDeleteArray(T* p);
    00408
    00409 #ifdef FBXSDK_COMPILER_MSC
    00410     #pragma warning(pop)
    00411 #endif
    00412
    00413 #include <fbxsdk/fbxsdk_nsend.h>
    00414
    00415 #endif /* _FBXSDK_CORE_ARCH_NEW_H_ */