FBX SDK Reference Guide: kfbxprocessorxref.h Source File
00001 #ifndef FBXFILESDK_FBXPROCESSORS_KFBXPROCESSORXREF_H
00002 #define FBXFILESDK_FBXPROCESSORS_KFBXPROCESSORXREF_H
00003 
00004 /**************************************************************************************
00005 
00006  Copyright © 2001 - 2006 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 <fbxfilesdk/fbxprocessors/fbxprocessors_def.h>
00040 
00041 #include <fbxfilesdk/fbxprocessors/kfbxprocessor.h>
00042 #include <fbxfilesdk/components/kbaselib/klib/kmap.h>
00043 
00044 namespace FBXPROCESSORS_NAMESPACE {
00045 
00053     class KFBX_DLL KFbxProcessorXRefCopy : public KFbxProcessor
00054     {
00055         KFBXOBJECT_DECLARE(KFbxProcessorXRefCopy,KFbxProcessor);
00056 
00057         class KFBX_DLL KFbxMissingUrlHandler
00058         {
00059         public:
00060             virtual ~KFbxMissingUrlHandler();
00061             virtual void MissingUrl(const KString& pUrl, const KFbxProperty&) = 0;
00062         };
00063 
00068         public:
00069             KFbxTypedProperty<fbxString>    OutputDirectory;
00070 
00071             // As we resolve xref and copy assets, do we update properties to
00072             // now use this relative path?  Defaults to TRUE.
00073             KFbxTypedProperty<fbxBool1>     UpdateProperties;
00074 
00075             // Default to FALSE -- when set, this informs the processor to track
00076             // every properties that were modified during the scene processing.
00077             KFbxTypedProperty<fbxBool1>     TrackUpdatedProperties;
00078 
00079             // Default to TRUE -- when not set, files are only copied if one of
00080             // the following conditions is met:
00081             //
00082             //  1) Target does not exist
00083             //  2) Target has a different time
00084             //  3) Target has a different size
00085             KFbxTypedProperty<fbxBool1>     ForceCopy;
00086 
00087             // Default to TRUE -- when copying a file, also copy its modification
00088             // time.  A bit of a requirement if you're not going to use ForceCopy.
00089             KFbxTypedProperty<fbxBool1>     CopyFileTimes;
00091 
00092             // Optional callback; when set, this will be called when an Url cannot be
00093             // be copied because the source is not found.
00094             // Memory is owned by the client code, and will not be freed by us.
00095             KFbxMissingUrlHandler*          MissingUrlHandler;
00096 
00097         // Since KFbxProperty is an opaque type, we can't do an efficient operator <
00098         // on it, and must keep the data on the object, which can be compared through
00099         // pointers, and then we can further compare against the property name.
00100         struct KFbxPropertyUpdate
00101         {
00102             KFbxProperty mProperty;
00103             fbxString    mOriginalValue;
00104 
00105             inline KFbxPropertyUpdate() {}
00106             inline KFbxPropertyUpdate(const KFbxProperty& pProp, const fbxString& pVal) :
00107                 mProperty(pProp), mOriginalValue(pVal) {}
00108 
00109             inline bool operator <(const KFbxPropertyUpdate& pOther) const
00110             {
00111                 return strcmp(mProperty.GetName(), pOther.mProperty.GetName()) < 0;
00112             }
00113         };
00114         typedef KSet2<KFbxPropertyUpdate>           KFbxUpdateSet;
00115         typedef KMap<KFbxObject*, KFbxUpdateSet>    KFbxPropertyUpdateMap;
00116 
00117         // All properties that were updated, with their original value.
00118         // Will always be empty if TrackUpdatedProperties
00119         // was not set before calling ProcessCollection/ProcessObject.
00120         // NOT cleared before each processing run.
00121         KFbxPropertyUpdateMap& GetUpdatedProperties();
00122 
00123         // If property tracking was enabled, goes through and reverts all changes
00124         // to the properties.  Does not un-copy the files, naturally.
00125         void RevertPropertyChanges();
00126 
00127         // This is just a safety net to make sure RevertPropertyChanges is called when
00128         // this goes out of scope.
00129         struct KFBX_DLL KFbxAutoRevertPropertyChanges
00130         {
00131             KFbxAutoRevertPropertyChanges(KFbxProcessorXRefCopy* pCopy) : mXRefCopy(pCopy) {}
00132             ~KFbxAutoRevertPropertyChanges()
00133             {
00134                 if( mXRefCopy )
00135                     mXRefCopy->RevertPropertyChanges();
00136             }
00137 
00138             KFbxProcessorXRefCopy* mXRefCopy;
00139         };
00140 
00142         //  WARNING!
00143         //  Anything beyond these lines may not be Collectioned accurately and is
00144         //  subject to change without notice.
00146         #ifndef DOXYGEN_SHOULD_SKIP_THIS
00147 
00148             protected:
00149                 KFbxPropertyUpdateMap       mUpdatedProperties;
00150 
00151             // Constructor / Destructor
00152             protected:
00153                 virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00154                 KFbxProcessorXRefCopy(KFbxSdkManager& pManager, char const* pName);
00155                 ~KFbxProcessorXRefCopy();
00156                 virtual void Construct  (const KFbxProcessorXRefCopy* pFrom);
00157                 virtual void Destruct   (bool pRecursive, bool pDependents);
00158                 bool    ConstructProperties(bool pForceSet);
00159                 KFbxProcessorXRefCopy& operator=(const KFbxProcessorXRefCopy&);
00160 
00161                 // Implements the rules specified for the ForceCopy property.
00162                 // Also checks the ForceCopy property.
00163                 bool ShouldCopyFile(const KString& pTarget, const KString& pSource) const;
00164 
00168             protected:
00169                 virtual bool                internal_ProcessCollectionBegin (KFbxCollection*     pObject);
00170                 virtual bool                internal_ProcessCollectionEnd   (KFbxCollection*     pObject);
00171                 virtual bool                internal_ProcessObject          (KFbxObject*     pObject);
00172                 bool                        ProcessPathProperty(KFbxProperty &pProperty);
00173                 virtual bool                ValidPropertyForXRefCopy(KFbxObject* pObject, KFbxProperty& lProperty) const;
00175 
00176         #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00177 
00178     };
00179 }
00180 
00181 #endif // FBXFILESDK_FBXPROCESSORS_KFBXPROCESSORXREF_H
00182