00001 /**************************************************************************************** 00002 00003 Copyright (C) 2013 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 00013 #ifndef _FBXSDK_CORE_QUERY_H_ 00014 #define _FBXSDK_CORE_QUERY_H_ 00015 00016 #include <fbxsdk/fbxsdk_def.h> 00017 00018 #include <fbxsdk/core/fbxclassid.h> 00019 #include <fbxsdk/core/fbxconnectionpoint.h> 00020 #include <fbxsdk/core/base/fbxmap.h> 00021 #include <fbxsdk/core/base/fbxmemorypool.h> 00022 00023 #include <fbxsdk/fbxsdk_nsbegin.h> 00024 00025 #define FBXSDK_QUERY_UNIQUE_ID 0x14000000 00026 00027 class FbxProperty; 00028 00032 class FBXSDK_DLL FbxQuery 00033 { 00034 public: 00036 virtual FbxInt GetUniqueId() const { return FBXSDK_QUERY_UNIQUE_ID; } 00037 00041 virtual bool IsValid(const FbxProperty& pProperty) const; 00042 00045 virtual bool IsEqual(FbxQuery* pOtherQuery) const; 00046 00048 void Ref(); 00049 00051 void Unref(); 00052 00053 /***************************************************************************************************************************** 00054 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** 00055 *****************************************************************************************************************************/ 00056 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00057 protected: 00058 FbxQuery(); 00059 virtual ~FbxQuery(); 00060 00061 static void InitializeMemoryPool(); 00062 static void ReleaseMemoryPool(); 00063 static FbxMemoryPool* GetMemoryPool(); 00064 00065 private: 00066 class InternalFilter : public FbxConnectionPointFilter 00067 { 00068 public: 00069 InternalFilter(FbxQuery* pQuery); 00070 ~InternalFilter(); 00071 00072 public: 00073 FbxConnectionPointFilter* Ref(); 00074 void Unref(); 00075 FbxInt GetUniqueId() const { return mQuery->GetUniqueId(); } 00076 bool IsValid(FbxConnectionPoint* pConnect) const; 00077 bool IsEqual(FbxConnectionPointFilter* pConnectFilter) const; 00078 00079 FbxQuery* mQuery; 00080 }; 00081 00082 InternalFilter mFilter; 00083 int mRefCount; 00084 static FbxMemoryPool* mMemPool; 00085 00086 FBXSDK_FRIEND_NEW(); 00087 friend class FbxProperty; 00088 friend class FbxManager; 00089 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ 00090 }; 00091 00110 class FBXSDK_DLL FbxCriteria 00111 { 00112 public: 00115 FbxCriteria(const FbxCriteria& pCriteria); 00116 00120 static FbxCriteria ObjectType(const FbxClassId& pClassId); 00121 00124 static FbxCriteria ObjectTypeStrict(const FbxClassId& pClassId); 00125 00127 static FbxCriteria IsProperty(); 00128 00131 FbxCriteria& operator=(const FbxCriteria& pCriteria); 00132 00135 FbxCriteria operator&&(const FbxCriteria& pCriteria) const; 00136 00139 FbxCriteria operator||(const FbxCriteria& pCriteria) const; 00140 00142 FbxCriteria operator!() const; 00143 00146 FbxQuery* GetQuery() const; 00147 00148 /***************************************************************************************************************************** 00149 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** 00150 *****************************************************************************************************************************/ 00151 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00152 FbxCriteria(); 00153 FbxCriteria(FbxQuery* pQuery) : mQuery(pQuery) {} 00154 ~FbxCriteria(); 00155 00156 private: 00157 FbxQuery* mQuery; 00158 00159 static void FreeGlobalCache(); 00160 00161 class ClassIdCompare 00162 { 00163 public: 00164 inline int operator() (const FbxClassId& pKeyA, const FbxClassId& pKeyB) const 00165 { 00166 const FbxClassIdInfo* lKeyA = pKeyA.GetClassIdInfo(); 00167 const FbxClassIdInfo* lKeyB = pKeyB.GetClassIdInfo(); 00168 return (lKeyA > lKeyB) ? 1 : (lKeyA < lKeyB) ? -1 : 0; 00169 } 00170 }; 00171 00172 class ClassIdCache 00173 { 00174 public: 00175 ClassIdCache(); 00176 ~ClassIdCache(); 00177 00178 FbxCriteria* GetObjectType(const FbxClassId& pClassId); 00179 static ClassIdCache* Get(); 00180 static void Destroy(); 00181 static FbxCriteria::ClassIdCache* mCache; 00182 00183 private: 00184 typedef FbxMap<FbxClassId, FbxCriteria*, ClassIdCompare> CriteriaCacheMap; 00185 CriteriaCacheMap mObjectTypeCriteria; 00186 }; 00187 00188 FBXSDK_FRIEND_NEW(); 00189 friend class FbxManager; 00190 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ 00191 }; 00192 00193 /***************************************************************************************************************************** 00194 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** 00195 *****************************************************************************************************************************/ 00196 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00197 class FBXSDK_DLL FbxQueryOperator : public FbxQuery 00198 { 00199 public: 00200 FBXSDK_FRIEND_NEW(); 00201 00202 enum EType {eAND, eOR}; 00203 00204 static FbxQueryOperator* Create(FbxQuery* pA, EType pOperator, FbxQuery* pB); 00205 virtual FbxInt GetUniqueId() const { return FBXSDK_QUERY_UNIQUE_ID+1; } 00206 virtual bool IsValid(const FbxProperty& pProperty) const; 00207 virtual bool IsEqual(FbxQuery* pOtherQuery) const; 00208 00209 protected: 00210 FbxQueryOperator(FbxQuery* pA, EType pOperator, FbxQuery* pB); 00211 virtual ~FbxQueryOperator(); 00212 00213 private: 00214 FbxQuery *mA, *mB; 00215 EType mOperator; 00216 }; 00217 00218 class FBXSDK_DLL FbxQueryOperatorUnary : public FbxQuery 00219 { 00220 public: 00221 FBXSDK_FRIEND_NEW(); 00222 00223 static FbxQueryOperatorUnary* Create(FbxQuery* pA); 00224 virtual FbxInt GetUniqueId() const{ return FBXSDK_QUERY_UNIQUE_ID+2; } 00225 virtual bool IsValid(const FbxProperty& pProperty) const; 00226 virtual bool IsEqual(FbxQuery* pOtherQuery) const; 00227 00228 protected: 00229 FbxQueryOperatorUnary(FbxQuery* pA); 00230 virtual ~FbxQueryOperatorUnary(); 00231 00232 private: 00233 FbxQuery* mA; 00234 }; 00235 00236 class FBXSDK_DLL FbxQueryClassId : public FbxQuery 00237 { 00238 public: 00239 FBXSDK_FRIEND_NEW(); 00240 00241 static FbxQueryClassId* Create(const FbxClassId& pClassId); 00242 virtual FbxInt GetUniqueId() const{ return FBXSDK_QUERY_UNIQUE_ID+3; } 00243 virtual bool IsValid(const FbxProperty& pProperty) const; 00244 virtual bool IsEqual(FbxQuery* pOtherQuery) const; 00245 00246 protected: 00247 FbxQueryClassId(const FbxClassId& pClassId); 00248 00249 private: 00250 FbxClassId mClassId; 00251 }; 00252 00253 class FBXSDK_DLL FbxQueryIsA : public FbxQuery 00254 { 00255 public: 00256 FBXSDK_FRIEND_NEW(); 00257 00258 static FbxQueryIsA* Create(const FbxClassId& pClassId); 00259 virtual FbxInt GetUniqueId() const{ return FBXSDK_QUERY_UNIQUE_ID+4; } 00260 virtual bool IsValid(const FbxProperty& pProperty) const; 00261 virtual bool IsEqual(FbxQuery* pOtherQuery) const; 00262 00263 protected: 00264 FbxQueryIsA(const FbxClassId& pClassId); 00265 00266 private: 00267 FbxClassId mClassId; 00268 }; 00269 00270 class FBXSDK_DLL FbxQueryIsProperty : public FbxQuery 00271 { 00272 public: 00273 FBXSDK_FRIEND_NEW(); 00274 00275 static FbxQueryIsProperty* Create(); 00276 virtual FbxInt GetUniqueId() const{ return FBXSDK_QUERY_UNIQUE_ID+5; } 00277 virtual bool IsValid(const FbxProperty& pProperty) const; 00278 virtual bool IsEqual(FbxQuery* pOtherQuery) const; 00279 00280 protected: 00281 FbxQueryIsProperty(); 00282 }; 00283 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ 00284 00285 #include <fbxsdk/fbxsdk_nsend.h> 00286 00287 #endif /* _FBXSDK_CORE_QUERY_H_ */