00001 
00004 #ifndef FBXFILESDK_FBXCORE_KFBXQUERY_H
00005 #define FBXFILESDK_FBXCORE_KFBXQUERY_H
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00043 #include <fbxfilesdk/fbxcore/kfbxpropertydef.h>
00044 #include <fbxfilesdk/kfbxplugins/kfbxproperty.h>
00045 
00046 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00047 
00048 
00049     
00050 
00051 
00052 
00056     class KFBX_DLL KFbxQuery {
00057         
00058         public:
00060             virtual kFbxFilterId                    GetUniqueId() const     { return 0x1452e230; }
00061             
00066             virtual bool IsValid(KFbxProperty const &pProperty) const;
00067 
00073             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00074 
00079             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00080 
00081         public:
00083             void                                    Ref();
00085             void                                    Unref();
00086         protected:
00087             KFbxQuery();
00088             virtual ~KFbxQuery();
00089         private:
00090             class KFbxInternalFilter : public KFbxConnectionPointFilter{
00091                 public:
00092                     KFbxInternalFilter(KFbxQuery *pQuery);
00093                     ~KFbxInternalFilter();
00094 
00095                 
00096                 public:
00097                     KFbxConnectionPointFilter*      Ref();
00098                     void                            Unref();
00099                     kFbxFilterId                    GetUniqueId() const { return mQuery->GetUniqueId(); }
00100                     bool                            IsValid             (KFbxConnectionPoint*   pConnect) const;
00101                     bool                            IsValidConnection   (KFbxConnectionPoint*   pConnect,kFbxConnectionType pType) const;
00102                     bool                            IsEqual             (KFbxConnectionPointFilter* pConnectFilter) const;
00103                 public:
00104                     KFbxQuery*      mQuery;
00105 
00106             };
00107 
00108             KFbxInternalFilter  mFilter;
00109             int                 mRefCount;
00110 
00111             friend class KFbxProperty;
00112             friend class KFbxInternalFilter;
00113         };
00114 
00115     
00116 
00117 
00118     enum eFbxQueryOperator { eFbxAnd,eFbxOr } ;
00119 
00124     class KFBX_DLL KFbxQueryOperator : public KFbxQuery {
00125         
00126         public:
00132             static KFbxQueryOperator* Create(KFbxQuery* pA,eFbxQueryOperator pOperator,KFbxQuery* pB);
00133 
00134         protected:
00135             KFbxQueryOperator(KFbxQuery* pA,eFbxQueryOperator pOperator,KFbxQuery* pB);
00136             virtual ~KFbxQueryOperator();
00137 
00138         
00139         public:
00140 
00142             virtual kFbxFilterId    GetUniqueId() const{ return 0x945874; }
00143 
00148             virtual bool IsValid(KFbxProperty const &pProperty) const;
00149 
00155             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00156             
00161             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00162         private:
00163             KFbxQuery           *mA,*mB;
00164             eFbxQueryOperator   mOperator;
00165     };
00166 
00167     
00168 
00169 
00170     enum eFbxUnaryQueryOperator { eFbxNot };
00171 
00175     class KFBX_DLL KFbxUnaryQueryOperator : public KFbxQuery {
00176         
00177         public:
00182             static KFbxUnaryQueryOperator* Create(KFbxQuery* pA,eFbxUnaryQueryOperator pOperator);
00183 
00184         protected:
00185             KFbxUnaryQueryOperator(KFbxQuery* pA,eFbxUnaryQueryOperator pOperator);
00186             virtual ~KFbxUnaryQueryOperator();
00187 
00188         
00189         public:
00190 
00192             virtual kFbxFilterId    GetUniqueId() const{ return 0x945874BB; }
00193 
00198             virtual bool IsValid(KFbxProperty const &pProperty) const;
00199 
00205             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00206 
00211             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00212         private:
00213             KFbxQuery                *mA;
00214             eFbxUnaryQueryOperator   mOperator;
00215     };
00216 
00217     
00218 
00219 
00223     class KFBX_DLL KFbxQueryClassId : public KFbxQuery {
00224         
00225         public:
00229             static KFbxQueryClassId* Create(kFbxClassId pClassId);
00230 
00231         protected:
00232             KFbxQueryClassId(kFbxClassId pClassId);
00233 
00234         
00235         public:
00236 
00238             virtual kFbxFilterId    GetUniqueId() const{ return 0x14572785; }
00239 
00244             virtual bool IsValid(KFbxProperty const &pProperty) const;
00245 
00251             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00252 
00257             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00258         private:
00259             kFbxClassId             mClassId;
00260     };
00261 
00262     
00263 
00264 
00265 
00269     class KFBX_DLL KFbxQueryIsA : public KFbxQuery {
00270         
00271         public:
00275             static KFbxQueryIsA* Create(kFbxClassId pClassId);
00276 
00277         protected:
00278 
00282             KFbxQueryIsA(kFbxClassId pClassId);
00283 
00284         
00285         public:
00286 
00288             virtual kFbxFilterId    GetUniqueId() const{ return 0x1457278F; }
00289 
00294             virtual bool IsValid(KFbxProperty const &pProperty) const;
00295 
00301             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00302 
00307             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00308         private:
00309             kFbxClassId             mClassId;
00310     };
00311 
00312     
00313 
00314 
00315 
00319     class KFBX_DLL KFbxQueryProperty : public KFbxQuery {
00320         
00321         public:
00323             static KFbxQueryProperty* Create();
00324 
00325         protected:
00326             KFbxQueryProperty();
00327 
00328         
00329         public:
00330 
00332             virtual kFbxFilterId    GetUniqueId() const{ return 0x9348203; }
00333 
00338             virtual bool IsValid(KFbxProperty const &pProperty) const;
00339 
00345             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00346 
00350             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00351         private:
00352     };
00353 
00354     
00355 
00356 
00357 
00361     class KFBX_DLL KFbxQueryConnectionType : public KFbxQuery {
00362         
00363         public:
00364 
00368             static KFbxQueryConnectionType* Create(kFbxConnectionType pConnectionType);
00369 
00370         protected:
00371             KFbxQueryConnectionType(kFbxConnectionType pConnectionType);
00372 
00373         
00374         public:
00375 
00377             virtual kFbxFilterId    GetUniqueId() const{ return 0x14587275; }
00378 
00383             virtual bool IsValid(KFbxProperty const &pProperty) const;
00384 
00390             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00391 
00396             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00397         private:
00398             kFbxConnectionType              mConnectionType;
00399     };
00400 
00401     
00402 
00403 
00407     class KFbxCriteria {
00408         public:
00409             static KFbxCriteria ConnectionType(kFbxConnectionType pConnectionType)
00410             {
00411                 return KFbxCriteria(KFbxQueryConnectionType::Create(pConnectionType));
00412             }
00413             static KFbxCriteria ObjectType(kFbxClassId pClassId)       
00414             {
00415                 return KFbxCriteria(KFbxQueryClassId::Create(pClassId));
00416             }
00417             static KFbxCriteria ObjectIsA(kFbxClassId pClassId)        
00418             {
00419                 return KFbxCriteria(KFbxQueryIsA::Create(pClassId));
00420             }
00421             static KFbxCriteria Property()
00422             {
00423                 return KFbxCriteria(KFbxQueryProperty::Create());
00424             }
00425             inline KFbxCriteria()
00426                 : mQuery(0)
00427             {
00428             }
00429             inline KFbxCriteria(KFbxCriteria const &pCriteria)
00430                 : mQuery(pCriteria.mQuery)
00431             {
00432                 if( mQuery )
00433                     mQuery->Ref();
00434             }
00435 
00436             inline ~KFbxCriteria()
00437             {
00438                 if( mQuery )
00439                     mQuery->Unref();
00440             }
00441         private:
00442             inline KFbxCriteria(KFbxQuery* pQuery)
00443                 : mQuery(pQuery)
00444             {
00445             }
00446         public:
00447             inline KFbxCriteria &operator=(KFbxCriteria const &pCriteria)
00448             {
00449                 if( this != &pCriteria )
00450                 {
00451                     KFbxQuery* lQuery = mQuery;
00452                     mQuery = pCriteria.mQuery;
00453 
00454                     if( mQuery )
00455                         mQuery->Ref();
00456 
00457                     if( lQuery )
00458                         lQuery->Unref();
00459                 }
00460 
00461                 return *this;
00462             }
00463             inline KFbxCriteria operator && (KFbxCriteria const &pCriteria) const
00464             {
00465                 return KFbxCriteria(KFbxQueryOperator::Create(GetQuery(),eFbxAnd,pCriteria.GetQuery()));
00466             }
00467             inline KFbxCriteria operator || (KFbxCriteria const &pCriteria) const
00468             {
00469                 return KFbxCriteria(KFbxQueryOperator::Create(GetQuery(),eFbxOr,pCriteria.GetQuery()));
00470             }
00471             inline KFbxCriteria operator !() const
00472             {
00473                 return KFbxCriteria(KFbxUnaryQueryOperator::Create(GetQuery(), eFbxNot));
00474             }
00475 
00476         public:
00477             inline KFbxQuery*   GetQuery() const { return mQuery; }
00478         private:
00479             KFbxQuery*  mQuery;
00480     };
00481 
00482 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00483 
00484 #endif // FBXFILESDK_FBXCORE_KFBXQUERY_H
00485