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 - 2010 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 #include <fbxfilesdk/fbxfilesdk_def.h>
00042 
00043 #include <fbxfilesdk/fbxcore/kfbxpropertydef.h>
00044 #include <fbxfilesdk/kfbxplugins/kfbxproperty.h>
00045 
00046 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00047 
00048     /***********************************************
00049       KFbxQuery
00050     ************************************************/
00051 
00055     class KFBX_DLL KFbxQuery {
00056         // Overridable Test functions
00057         public:
00058             KFBXNEW_DECLARE_FRIEND
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:
00127             KFBXNEW_DECLARE_FRIEND
00133             static KFbxQueryOperator* Create(KFbxQuery* pA,eFbxQueryOperator pOperator,KFbxQuery* pB);
00134 
00135         protected:
00136             KFbxQueryOperator(KFbxQuery* pA,eFbxQueryOperator pOperator,KFbxQuery* pB);
00137             virtual ~KFbxQueryOperator();
00138 
00139         // Test functions
00140         public:
00141 
00143             virtual kFbxFilterId    GetUniqueId() const{ return 0x945874; }
00144 
00149             virtual bool IsValid(KFbxProperty const &pProperty) const;
00150 
00156             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00157             
00162             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00163         private:
00164             KFbxQuery           *mA,*mB;
00165             eFbxQueryOperator   mOperator;
00166     };
00167 
00168     /***********************************************
00169       KFbxUnaryQueryOperator
00170     ************************************************/
00171     enum eFbxUnaryQueryOperator { eFbxNot };
00172 
00176     class KFBX_DLL KFbxUnaryQueryOperator : public KFbxQuery {
00177         //
00178         public:
00179             KFBXNEW_DECLARE_FRIEND
00184             static KFbxUnaryQueryOperator* Create(KFbxQuery* pA,eFbxUnaryQueryOperator pOperator);
00185 
00186         protected:
00187             KFbxUnaryQueryOperator(KFbxQuery* pA,eFbxUnaryQueryOperator pOperator);
00188             virtual ~KFbxUnaryQueryOperator();
00189 
00190         // Test functions
00191         public:
00192 
00194             virtual kFbxFilterId    GetUniqueId() const{ return 0x945874BB; }
00195 
00200             virtual bool IsValid(KFbxProperty const &pProperty) const;
00201 
00207             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00208 
00213             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00214         private:
00215             KFbxQuery                *mA;
00216             eFbxUnaryQueryOperator   mOperator;
00217     };
00218 
00219     /***********************************************
00220       KFbxQueryClassId -- match anywhere in the hierarchy of an object.
00221     ************************************************/
00225     class KFBX_DLL KFbxQueryClassId : public KFbxQuery {
00226         //
00227         public:
00228             KFBXNEW_DECLARE_FRIEND
00232             static KFbxQueryClassId* Create(kFbxClassId pClassId);
00233 
00234         protected:
00235             KFbxQueryClassId(kFbxClassId pClassId);
00236 
00237         // Test functions
00238         public:
00239 
00241             virtual kFbxFilterId    GetUniqueId() const{ return 0x14572785; }
00242 
00247             virtual bool IsValid(KFbxProperty const &pProperty) const;
00248 
00254             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00255 
00260             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00261         private:
00262             kFbxClassId             mClassId;
00263     };
00264 
00265     /***********************************************
00266       KFbxQueryIsA -- Exact match.
00267     ************************************************/
00268 
00272     class KFBX_DLL KFbxQueryIsA : public KFbxQuery {
00273         //
00274         public:
00275             KFBXNEW_DECLARE_FRIEND
00279             static KFbxQueryIsA* Create(kFbxClassId pClassId);
00280 
00281         protected:
00282 
00286             KFbxQueryIsA(kFbxClassId pClassId);
00287 
00288         // Test functions
00289         public:
00290 
00292             virtual kFbxFilterId    GetUniqueId() const{ return 0x1457278F; }
00293 
00298             virtual bool IsValid(KFbxProperty const &pProperty) const;
00299 
00305             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00306 
00311             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00312         private:
00313             kFbxClassId             mClassId;
00314     };
00315 
00316     /***********************************************
00317       KFbxQueryProperty
00318     ************************************************/
00319 
00323     class KFBX_DLL KFbxQueryProperty : public KFbxQuery {
00324         //
00325         public:
00326             KFBXNEW_DECLARE_FRIEND
00328             static KFbxQueryProperty* Create();
00329 
00330         protected:
00331             KFbxQueryProperty();
00332 
00333         // Test functions
00334         public:
00335 
00337             virtual kFbxFilterId    GetUniqueId() const{ return 0x9348203; }
00338 
00343             virtual bool IsValid(KFbxProperty const &pProperty) const;
00344 
00350             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00351 
00355             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00356         private:
00357     };
00358 
00359     /***********************************************
00360       KFbxQueryConnectionType
00361     ************************************************/
00362 
00366     class KFBX_DLL KFbxQueryConnectionType : public KFbxQuery {
00367         //
00368         public:
00369             KFBXNEW_DECLARE_FRIEND
00370 
00374             static KFbxQueryConnectionType* Create(kFbxConnectionType pConnectionType);
00375 
00376         protected:
00377             KFbxQueryConnectionType(kFbxConnectionType pConnectionType);
00378 
00379         // Test functions
00380         public:
00381 
00383             virtual kFbxFilterId    GetUniqueId() const{ return 0x14587275; }
00384 
00389             virtual bool IsValid(KFbxProperty const &pProperty) const;
00390 
00396             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00397 
00402             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00403         private:
00404             kFbxConnectionType              mConnectionType;
00405     };
00406 
00407     /***********************************************
00408       KFbxCriteria
00409     ************************************************/
00410 
00435     class KFbxCriteria {
00436         public:
00440             static KFbxCriteria ConnectionType(kFbxConnectionType pConnectionType)
00441             {
00442                 return KFbxCriteria(KFbxQueryConnectionType::Create(pConnectionType));
00443             }
00448             static KFbxCriteria ObjectType(kFbxClassId pClassId)
00449             {
00450                 return KFbxCriteria(KFbxQueryClassId::Create(pClassId));
00451             }
00455             static KFbxCriteria ObjectIsA(kFbxClassId pClassId)
00456             {
00457                 return KFbxCriteria(KFbxQueryIsA::Create(pClassId));
00458             }
00460             static KFbxCriteria Property()
00461             {
00462                 return KFbxCriteria(KFbxQueryProperty::Create());
00463             }
00465             inline KFbxCriteria()
00466                 : mQuery(0)
00467             {
00468             }
00472             inline KFbxCriteria(KFbxCriteria const &pCriteria)
00473                 : mQuery(pCriteria.mQuery)
00474             {
00475                 if( mQuery )
00476                     mQuery->Ref();
00477             }
00478 
00480             inline ~KFbxCriteria()
00481             {
00482                 if( mQuery )
00483                     mQuery->Unref();
00484             }
00485 
00489             inline KFbxCriteria &operator=(KFbxCriteria const &pCriteria)
00490             {
00491                 if( this != &pCriteria )
00492                 {
00493                     KFbxQuery* lQuery = mQuery;
00494                     mQuery = pCriteria.mQuery;
00495 
00496                     if( mQuery )
00497                         mQuery->Ref();
00498 
00499                     if( lQuery )
00500                         lQuery->Unref();
00501                 }
00502 
00503                 return *this;
00504             }
00508             inline KFbxCriteria operator && (KFbxCriteria const &pCriteria) const
00509             {
00510                 return KFbxCriteria(KFbxQueryOperator::Create(GetQuery(),eFbxAnd,pCriteria.GetQuery()));
00511             }
00515             inline KFbxCriteria operator || (KFbxCriteria const &pCriteria) const
00516             {
00517                 return KFbxCriteria(KFbxQueryOperator::Create(GetQuery(),eFbxOr,pCriteria.GetQuery()));
00518             }
00520             inline KFbxCriteria operator !() const
00521             {
00522                 return KFbxCriteria(KFbxUnaryQueryOperator::Create(GetQuery(), eFbxNot));
00523             }
00527             inline KFbxQuery*   GetQuery() const { return mQuery; }
00528 
00530             //
00531             //  WARNING!
00532             //
00533             //  Anything beyond these lines may not be documented accurately and is
00534             //  subject to change without notice.
00535             //
00537 
00538 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00539 
00540         private:
00541             KFbxQuery*  mQuery;
00542             inline KFbxCriteria(KFbxQuery* pQuery)
00543                 : mQuery(pQuery)
00544             {
00545             }
00546 #endif
00547     };
00548 
00549 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00550 
00551 #endif // FBXFILESDK_FBXCORE_KFBXQUERY_H
00552