kfbximplementationutils.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002 
00003    Copyright (C) 2010 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 
00014 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXIMPLEMENTATIONUTILS_H 
00015 #define FBXFILESDK_KFBXPLUGINS_KFBXIMPLEMENTATIONUTILS_H
00016 
00017 #include <fbxfilesdk/fbxfilesdk_def.h>
00018 
00019 #include <fbxfilesdk/kfbxplugins/kfbximplementation.h>
00020 #include <fbxfilesdk/kfbxplugins/kfbxbindingoperator.h>
00021 #include <fbxfilesdk/kfbxplugins/kfbxoperatorentryview.h>
00022 #include <fbxfilesdk/kfbxplugins/kfbxpropertyentryview.h>
00023 
00024 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00025 
00031 KFBX_DLL KFbxImplementation const* GetImplementation( KFbxObject const* pObject, char const* pImplementationTarget );
00032 
00041 template <typename T> bool GetBoundPropertyValue(KFbxBindingTable const* pBindingTable,
00042                                                  char const* pEntryName, 
00043                                                  KFbxImplementation const* pImplementation,
00044                                                  KFbxObject const* pBoundObject,
00045                                                  T& pValue)
00046 {
00047     if ((NULL != pImplementation) && (NULL != pBindingTable) && (NULL != pBoundObject) && (NULL != pEntryName))
00048     {
00049         KFbxBindingTableEntry const* lEntry = pBindingTable->GetEntryForDestination(pEntryName);
00050 
00051         if (NULL != lEntry)
00052         {
00053             if (strcmp(lEntry->GetEntryType(true), KFbxPropertyEntryView::sEntryType) == 0)
00054             {
00055                 char const* lPropName = lEntry->GetSource();
00056                 KFbxProperty lProp = pBoundObject->FindPropertyHierarchical(lPropName);
00057                 if (lProp.IsValid())
00058                 {
00059                     KFbxGet(lProp, pValue);
00060                     return true;
00061                 }
00062             }
00063             else if (strcmp(lEntry->GetEntryType(true), KFbxOperatorEntryView::sEntryType) == 0)
00064             {
00065                 char const* lOperatorName = lEntry->GetSource();
00066                 KFbxBindingOperator const* lOp = pImplementation->GetOperatorByTargetName(lOperatorName);
00067                 if (lOp)
00068                 {
00069                     return lOp->Evaluate(pBoundObject, &pValue);
00070                 }
00071             }
00072         }
00073     }
00074 
00075     return false;
00076 }
00077 
00078 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00079 
00080 #endif // FBXFILESDK_KFBXPLUGINS_KFBXIMPLEMENTATIONUTILS_H
00081