kfbxquery.h

Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_FBXCORE_KFBXQUERY_H
00005 #define FBXFILESDK_FBXCORE_KFBXQUERY_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright (C) 2001 - 2009 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
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       KFbxQuery
00051     ************************************************/
00052 
00056     class KFBX_DLL KFbxQuery {
00057         // Overridable Test functions
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                 // internal functions
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       KFbxQueryOperator (binary operators)
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         // Test functions
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       KFbxUnaryQueryOperator
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         // Test functions
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       KFbxQueryClassId -- match anywhere in the hierarchy of an object.
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         // Test functions
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       KFbxQueryIsA -- Exact match.
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         // Test functions
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       KFbxQueryProperty
00314     ************************************************/
00315 
00319     class KFBX_DLL KFbxQueryProperty : public KFbxQuery {
00320         //
00321         public:
00323             static KFbxQueryProperty* Create();
00324 
00325         protected:
00326             KFbxQueryProperty();
00327 
00328         // Test functions
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       KFbxQueryConnectionType
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         // Test functions
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       KFbxCriteria
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)       // Hierarchy match
00414             {
00415                 return KFbxCriteria(KFbxQueryClassId::Create(pClassId));
00416             }
00417             static KFbxCriteria ObjectIsA(kFbxClassId pClassId)        // Exact match
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