FBX SDK Reference Guide: kfbxquery.h Source File
00001 #ifndef _FBXSDK_QUERY_H_
00002 #define _FBXSDK_QUERY_H_
00003 
00004 /**************************************************************************************
00005 
00006  Copyright ?2001 - 2008 Autodesk, Inc. and/or its licensors.
00007  All Rights Reserved.
00008 
00009  The coded instructions, statements, computer programs, and/or related material 
00010  (collectively the "Data") in these files contain unpublished information 
00011  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00012  Canada and United States of America federal copyright law and by international 
00013  treaties. 
00014  
00015  The Data may not be disclosed or distributed to third parties, in whole or in
00016  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00017 
00018  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00019  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00020  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00021  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00022  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00023  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00024  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00025  
00026  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00027  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00028  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00029  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00030  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00031  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00032  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00033  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00034  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00035  OR DAMAGE. 
00036 
00037 **************************************************************************************/
00038 
00039 #include <kaydaradef.h>
00040 #ifndef KFBX_DLL
00041     #define KFBX_DLL K_DLLIMPORT
00042 #endif
00043 
00044 #include <fbxcore/kfbxpropertydef.h>
00045 #include <kfbxplugins/kfbxproperty.h>
00046 
00047 #include <fbxfilesdk_nsbegin.h>
00048 
00049 
00050     /***********************************************
00051       KFbxQuery
00052     ************************************************/
00053 
00057     class KFBX_DLL KFbxQuery {
00058         // Overridable Test functions
00059         public:
00061             virtual kFbxFilterId                    GetUniqueId() const     { return 0x1452e230; }
00062             
00064             virtual bool IsValid(KFbxProperty const &pProperty) const;
00066             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00067 
00072             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00073 
00074         public:
00076             void                                    Ref();
00078             void                                    Unref();
00079         protected:
00080             KFbxQuery();
00081             virtual ~KFbxQuery();
00082         private:
00083             class KFbxInternalFilter : public KFbxConnectionPointFilter{
00084                 public:
00085                     KFbxInternalFilter(KFbxQuery *pQuery);
00086                     ~KFbxInternalFilter();
00087 
00088                 // internal functions
00089                 public:
00090                     KFbxConnectionPointFilter*      Ref();
00091                     void                            Unref();
00092                     kFbxFilterId                    GetUniqueId() const { return mQuery->GetUniqueId(); }
00093                     bool                            IsValid             (KFbxConnectionPoint*   pConnect) const;
00094                     bool                            IsValidConnection   (KFbxConnectionPoint*   pConnect,kFbxConnectionType pType) const;
00095                     bool                            IsEqual             (KFbxConnectionPointFilter* pConnectFilter) const;
00096                 public:
00097                     KFbxQuery*      mQuery;
00098 
00099             };
00100 
00101             KFbxInternalFilter  mFilter;
00102             int                 mRefCount;
00103 
00104             friend class KFbxProperty;
00105             friend class KFbxInternalFilter;
00106         };
00107 
00108     /***********************************************
00109       KFbxQueryOperator (binary operators)
00110     ************************************************/
00111     enum eFbxQueryOperator { eFbxAnd,eFbxOr } ;
00112 
00117     class KFBX_DLL KFbxQueryOperator : public KFbxQuery {
00118         //
00119         public:
00121             static KFbxQueryOperator* Create(KFbxQuery* pA,eFbxQueryOperator pOperator,KFbxQuery* pB);
00122 
00123         protected:
00124             KFbxQueryOperator(KFbxQuery* pA,eFbxQueryOperator pOperator,KFbxQuery* pB);
00125             virtual ~KFbxQueryOperator();
00126 
00127         // Test functions
00128         public:
00129 
00131             virtual kFbxFilterId    GetUniqueId() const{ return 0x945874; }
00132 
00134             virtual bool IsValid(KFbxProperty const &pProperty) const;
00135 
00137             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00138             
00140             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00141         private:
00142             KFbxQuery           *mA,*mB;
00143             eFbxQueryOperator   mOperator;
00144     };
00145 
00146     /***********************************************
00147       KFbxUnaryQueryOperator
00148     ************************************************/
00149     enum eFbxUnaryQueryOperator { eFbxNot };
00150 
00154     class KFBX_DLL KFbxUnaryQueryOperator : public KFbxQuery {
00155         //
00156         public:
00158             static KFbxUnaryQueryOperator* Create(KFbxQuery* pA,eFbxUnaryQueryOperator pOperator);
00159 
00160         protected:
00161             KFbxUnaryQueryOperator(KFbxQuery* pA,eFbxUnaryQueryOperator pOperator);
00162             virtual ~KFbxUnaryQueryOperator();
00163 
00164         // Test functions
00165         public:
00166 
00168             virtual kFbxFilterId    GetUniqueId() const{ return 0x945874BB; }
00169 
00171             virtual bool IsValid(KFbxProperty const &pProperty) const;
00172 
00174             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00175 
00177             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00178         private:
00179             KFbxQuery                *mA;
00180             eFbxUnaryQueryOperator   mOperator;
00181     };
00182 
00183     /***********************************************
00184       KFbxQueryClassId -- match anywhere in the hierarchy of an object.
00185     ************************************************/
00189     class KFBX_DLL KFbxQueryClassId : public KFbxQuery {
00190         //
00191         public:
00193             static KFbxQueryClassId* Create(kFbxClassId pClassId);
00194 
00195         protected:
00196             KFbxQueryClassId(kFbxClassId pClassId);
00197 
00198         // Test functions
00199         public:
00200 
00202             virtual kFbxFilterId    GetUniqueId() const{ return 0x14572785; }
00203 
00205             virtual bool IsValid(KFbxProperty const &pProperty) const;
00207             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00208 
00210             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00211         private:
00212             kFbxClassId             mClassId;
00213     };
00214 
00215     /***********************************************
00216       KFbxQueryIsA -- Exact match.
00217     ************************************************/
00218 
00222     class KFBX_DLL KFbxQueryIsA : public KFbxQuery {
00223         //
00224         public:
00226             static KFbxQueryIsA* Create(kFbxClassId pClassId);
00227 
00228         protected:
00229             KFbxQueryIsA(kFbxClassId pClassId);
00230 
00231         // Test functions
00232         public:
00233 
00235             virtual kFbxFilterId    GetUniqueId() const{ return 0x1457278F; }
00236 
00238             virtual bool IsValid(KFbxProperty const &pProperty) const;
00239 
00241             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00242 
00244             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00245         private:
00246             kFbxClassId             mClassId;
00247     };
00248 
00249     /***********************************************
00250       KFbxQueryProperty
00251     ************************************************/
00252 
00256     class KFBX_DLL KFbxQueryProperty : public KFbxQuery {
00257         //
00258         public:
00260             static KFbxQueryProperty* Create();
00261 
00262         protected:
00263             KFbxQueryProperty();
00264 
00265         // Test functions
00266         public:
00267 
00269             virtual kFbxFilterId    GetUniqueId() const{ return 0x9348203; }
00270 
00272             virtual bool IsValid(KFbxProperty const &pProperty) const;
00273 
00275             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00277             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00278         private:
00279     };
00280 
00281     /***********************************************
00282       KFbxQueryConnectionType
00283     ************************************************/
00284 
00288     class KFBX_DLL KFbxQueryConnectionType : public KFbxQuery {
00289         //
00290         public:
00291 
00293             static KFbxQueryConnectionType* Create(kFbxConnectionType pConnectionType);
00294 
00295         protected:
00296             KFbxQueryConnectionType(kFbxConnectionType pConnectionType);
00297 
00298         // Test functions
00299         public:
00300 
00302             virtual kFbxFilterId    GetUniqueId() const{ return 0x14587275; }
00303 
00305             virtual bool IsValid(KFbxProperty const &pProperty) const;
00307             virtual bool IsValid(KFbxProperty const &pProperty,kFbxConnectionType pType) const;
00309             virtual bool IsEqual(KFbxQuery *pOtherQuery)    const;
00310         private:
00311             kFbxConnectionType              mConnectionType;
00312     };
00313 
00314     /***********************************************
00315       KFbxCriteria
00316     ************************************************/
00317     class KFbxCriteria {
00318         public:
00319             static KFbxCriteria ConnectionType(kFbxConnectionType pConnectionType)
00320             {
00321                 return KFbxCriteria(KFbxQueryConnectionType::Create(pConnectionType));
00322             }
00323             static KFbxCriteria ObjectType(kFbxClassId pClassId)       // Hierarchy match
00324             {
00325                 return KFbxCriteria(KFbxQueryClassId::Create(pClassId));
00326             }
00327             static KFbxCriteria ObjectIsA(kFbxClassId pClassId)        // Exact match
00328             {
00329                 return KFbxCriteria(KFbxQueryIsA::Create(pClassId));
00330             }
00331             static KFbxCriteria Property()
00332             {
00333                 return KFbxCriteria(KFbxQueryProperty::Create());
00334             }
00335             inline KFbxCriteria()
00336                 : mQuery(0)
00337             {
00338             }
00339             inline KFbxCriteria(KFbxCriteria const &pCriteria)
00340                 : mQuery(pCriteria.mQuery)
00341             {
00342                 if( mQuery )
00343                     mQuery->Ref();
00344             }
00345 
00346             inline ~KFbxCriteria()
00347             {
00348                 if( mQuery )
00349                     mQuery->Unref();
00350             }
00351         private:
00352             inline KFbxCriteria(KFbxQuery* pQuery)
00353                 : mQuery(pQuery)
00354             {
00355             }
00356         public:
00357             inline KFbxCriteria &operator=(KFbxCriteria const &pCriteria)
00358             {
00359                 if( this != &pCriteria )
00360                 {
00361                     KFbxQuery* lQuery = mQuery;
00362                     mQuery = pCriteria.mQuery;
00363 
00364                     if( mQuery )
00365                         mQuery->Ref();
00366 
00367                     if( lQuery )
00368                         lQuery->Unref();
00369                 }
00370 
00371                 return *this;
00372             }
00373             inline KFbxCriteria operator && (KFbxCriteria const &pCriteria) const
00374             {
00375                 return KFbxCriteria(KFbxQueryOperator::Create(GetQuery(),eFbxAnd,pCriteria.GetQuery()));
00376             }
00377             inline KFbxCriteria operator || (KFbxCriteria const &pCriteria) const
00378             {
00379                 return KFbxCriteria(KFbxQueryOperator::Create(GetQuery(),eFbxOr,pCriteria.GetQuery()));
00380             }
00381             inline KFbxCriteria operator !() const
00382             {
00383                 return KFbxCriteria(KFbxUnaryQueryOperator::Create(GetQuery(), eFbxNot));
00384             }
00385 
00386         public:
00387             inline KFbxQuery*   GetQuery() const { return mQuery; }
00388         private:
00389             KFbxQuery*  mQuery;
00390     };
00391 
00392 #include <fbxfilesdk_nsend.h>
00393 
00394 #endif // #ifndef _FBXSDK_Document_H_
00395 
00396