PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/fbxsdk/include/fbxfilesdk/kfbxplugins/kfbxclonemanager.h

http://monoxna.googlecode.com/
C Header | 172 lines | 49 code | 28 blank | 95 comment | 0 complexity | 07cbd4a13285719a14bdf29cb722c30a MD5 | raw file
Possible License(s): MIT
  1. /*! \file kfbxclonemanager.h
  2. */
  3. #ifndef FBXFILESDK_KFBXPLUGINS_KFBXCLONEMANAGER_H
  4. #define FBXFILESDK_KFBXPLUGINS_KFBXCLONEMANAGER_H
  5. /**************************************************************************************
  6. Copyright Š 2001 - 2008 Autodesk, Inc. and/or its licensors.
  7. All Rights Reserved.
  8. The coded instructions, statements, computer programs, and/or related material
  9. (collectively the "Data") in these files contain unpublished information
  10. proprietary to Autodesk, Inc. and/or its licensors, which is protected by
  11. Canada and United States of America federal copyright law and by international
  12. treaties.
  13. The Data may not be disclosed or distributed to third parties, in whole or in
  14. part, without the prior written consent of Autodesk, Inc. ("Autodesk").
  15. THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
  16. ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
  17. WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
  18. BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE,
  19. NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE.
  20. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
  21. OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE.
  22. IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
  23. OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
  24. OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
  25. SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
  26. OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
  27. HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
  28. FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
  29. ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
  30. WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
  31. OR DAMAGE.
  32. **************************************************************************************/
  33. #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
  34. #include <fbxfilesdk/components/kbaselib/kaydara.h>
  35. #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
  36. #include <fbxfilesdk/fbxcore/kfbxquery.h>
  37. #include <fbxfilesdk/fbxcore/fbxcollection/kfbxpropertymap.h>
  38. #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
  39. #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
  40. /** \brief The clone manager is a utility for cloning entire networks of KFbxObjects.
  41. * Options are availible for specifying how the clones inherit the connections
  42. * of the original.
  43. *
  44. * \nosubgrouping
  45. */
  46. class KFBX_DLL KFbxCloneManager
  47. {
  48. public:
  49. //! Maximum depth to clone dependents.
  50. static const int sMaximumCloneDepth;
  51. //! connect to objects that are connected to original object
  52. static const int sConnectToOriginal;
  53. /** connect to clones of objects that are connected to original object
  54. * (only if those original objects are also in the clone set)
  55. */
  56. static const int sConnectToClone;
  57. /** This represents an element in a set of objects to be cloned
  58. */
  59. struct KFBX_DLL CloneSetElement
  60. {
  61. public:
  62. CloneSetElement( int pSrcPolicy = 0,
  63. int pExternalDstPolicy = 0,
  64. KFbxObject::ECloneType pCloneType = KFbxObject::eREFERENCE_CLONE );
  65. //! the type of cloning to perform
  66. KFbxObject::ECloneType mType;
  67. /** Policy on how to handle source connections on the original object. Valid values are 0
  68. * or any bitwise OR'd combination of sConnectToOriginal, and sConnectToClone.
  69. */
  70. int mSrcPolicy;
  71. /** policy on how to handle destination connections on the original object to
  72. * objects NOT in the clone set. (Destination connections to objects in the set
  73. * are handled by that object's source policy) Valid values are 0 or sConnectToOriginal.
  74. */
  75. int mExternalDstPolicy;
  76. /** This is a pointer to the newly created clone.
  77. * It is set after the call to KFbxCloneManager::Clone()
  78. */
  79. KFbxObject* mObjectClone;
  80. };
  81. /** Functor to compare object pointers
  82. */
  83. class KFBX_DLL KFbxObjectCompare {
  84. public:
  85. inline int operator()(KFbxObject* const& pKeyA, KFbxObject* const& pKeyB) const
  86. {
  87. return (pKeyA < pKeyB) ? -1 : ((pKeyB < pKeyA) ? 1 : 0);
  88. }
  89. };
  90. /** The CloneSet is a collection of pointers to objects that will be cloned in Clone()
  91. * Attached to each object is a CloneSetElement. Its member variables dictate how
  92. * the corresponding object will be cloned, and how it will inherit connections
  93. * on the original object.
  94. */
  95. typedef KMap<KFbxObject*,CloneSetElement,KFbxObjectCompare> CloneSet;
  96. /** Constructor
  97. */
  98. KFbxCloneManager();
  99. /** Destructor
  100. */
  101. virtual ~KFbxCloneManager();
  102. /** Clone all objects in the set using the given policies for duplication
  103. * of connections. Each CloneSetElement in the set will have its mObjectClone
  104. * pointer set to the newly created clone.
  105. * \param pSet Set of objects to clone
  106. * \param pContainer This object (typically a scene or document) will contain the new clones
  107. * \return true if all objects were cloned, false otherwise.
  108. */
  109. virtual bool Clone( CloneSet& pSet, KFbxObject* pContainer = NULL ) const;
  110. /** Add all dependents of the given object to the CloneSet.
  111. * Dependents of items already in the set are ignored to prevent
  112. * infinite recursion on cyclic dependencies.
  113. * \param pSet The set to add items.
  114. * \param pObject Object to add dependents to
  115. * \param pCloneOptions
  116. * \param pTypes Types of dependent objects to consider
  117. * \param pDepth Maximum recursive depth. Valid range is [0,sMaximumCloneDepth]
  118. */
  119. virtual void AddDependents( CloneSet& pSet,
  120. const KFbxObject* pObject,
  121. const CloneSetElement& pCloneOptions = CloneSetElement(),
  122. KFbxCriteria pTypes = KFbxCriteria::ObjectType(KFbxObject::ClassId),
  123. int pDepth = sMaximumCloneDepth ) const;
  124. ///////////////////////////////////////////////////////////////////////////////
  125. //
  126. // WARNING!
  127. //
  128. // Anything beyond these lines may not be documented accurately and is
  129. // subject to change without notice.
  130. //
  131. ///////////////////////////////////////////////////////////////////////////////
  132. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  133. protected:
  134. bool CloneConnections( CloneSet::RecordType* pIterator, const CloneSet& pSet ) const;
  135. #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
  136. };
  137. #include <fbxfilesdk/fbxfilesdk_nsend.h>
  138. #endif // FBXFILESDK_KFBXPLUGINS_KFBXCLONEMANAGER_H