AcDbAssocDependencyBody.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. // CREATED BY: Jiri Kripac August 2007
  12. //
  13. // DESCRIPTION:
  14. //
  15. // AcDbAssocDependencyBody abstract base class for deriving custom dependency
  16. // body classes.
  17. //
  18. //////////////////////////////////////////////////////////////////////////////
  19. #pragma once
  20. #include "AcDbAssocDependency.h"
  21. #pragma pack (push, 8)
  22. /// <summary> <para>
  23. /// Abstract base class for deriving custom dependency body classes that implement
  24. /// functionality of custom dependencies.
  25. /// </para> <para>
  26. /// An object of a class derived from the AcDbAssocDependencyBody class is always
  27. /// owned by a parent AcDbAssocDependency object. The AcDbAssocDependency object has
  28. /// an AcDbHardOwnershipId on it and the AcDbAssocDependencyBody::ownerId() of the
  29. /// object returns the AcDbObjectId of its parent AcDbAssocDependency object.
  30. /// </para> <para>
  31. /// Therefore a custom dependency object (in the logical sense of the word "object")
  32. /// is always represented by a pair of physical AcDbObjects:
  33. ///
  34. /// - The parent dependency object of the AcDbAssocDependency class (or possibly, but
  35. /// less commonly, of a derived class).
  36. /// - The dependency body object of a custom class derived from the
  37. /// AcDbAssocDependencyBody abstract base class.
  38. ///
  39. /// </para> <para>
  40. /// This factoring out of the functionality of the custom dependencies into separate
  41. /// classes derived from the AcDbAssocDependencyBody class, instead of deriving the
  42. /// custom dependency classes directly from the AcDbAssocDependency class, allows
  43. /// better handling of the situations when the application code that implements
  44. /// the custom dependency behavior is not available. Only the custom object of the
  45. /// AcDbAssocDependencyBody-derived class will become a proxy, but its parent
  46. /// AcDbAssocDependency object will always be available and the associative mechanism
  47. /// can still function to some extent.
  48. /// </para> <para>
  49. /// The abstract AcDbAssocDependencyBody base class defines a set of virtual methods
  50. /// named xxxxxxOverride() that correspond to methods named xxxxxx() in the parent
  51. /// AcDbAssocDependency class. When a method xxxxxx() is called on the parent dependency
  52. /// object and the dependency object owns an dependency body object, the corresponding
  53. /// xxxxxxOverride() method on the dependency body object is called and it either
  54. /// supersedes or amends the default xxxxxx() implementation, depending on the
  55. /// particular method.
  56. /// </para> <para>
  57. /// If the dependency object does not own an dependency body object or if the
  58. /// dependency body object does not override the xxxxxxOverride() method, the default
  59. /// implementation in the parent dependency object is performed. Also, when the
  60. /// custom dependency body object becomes a proxy because its application code
  61. /// is not available, the parent dependency method just performs its default
  62. /// implementation.
  63. /// </para> <para>
  64. /// Custom dependency body classes derived from the AcDbAssocDependencyBody class
  65. /// implement their behavior by overriding the appropriate xxxxxxOverride()
  66. /// methods. Only the evaluateOverride() method must always be overridden in
  67. /// the custom classes. If not overridden, the other xxxxxxOverride() methods will
  68. /// do nothing and the default implementation in the parent AcDbAssocDependency
  69. /// object will be performed. This may be the appropriate behavior in most
  70. /// cases.
  71. /// </para> <para>
  72. /// Because each AcDbAssocDependencyBody object is owned by its parent
  73. /// AcDbAssocDependency object, erasing the parent AcDbAssocDependency object
  74. /// also erases the owned AcDbAssocDependencyBody object. There is no need to
  75. /// erase AcDbAssocDependencyBody objects explicitly.
  76. /// </para> </summary>
  77. ///
  78. class ACDB_PORT AcDbAssocDependencyBody : public AcDbObject
  79. {
  80. public:
  81. ACRX_DECLARE_MEMBERS(AcDbAssocDependencyBody);
  82. explicit AcDbAssocDependencyBody(AcDbAssocCreateImpObject createImpObject = kAcDbAssocCreateImpObject);
  83. virtual ~AcDbAssocDependencyBody();
  84. /// <summary>
  85. /// Returns AcDbObjectId of the parent AcDbAssocDependency that owns this
  86. /// dependency body object.
  87. /// </summary>
  88. ///
  89. AcDbObjectId parentDependency() const { return ownerId(); }
  90. // The following non-virtual methods are just shortcuts that just forward
  91. // to the parent AcDbAssocDependency class, to save some typing for the
  92. // implementers of the derived custom dependency body classes
  93. /// <summary>
  94. /// Just a shortcut, calls the method on the parent AcDbAssocDependency that
  95. /// owns this dependency body object.
  96. /// </summary>
  97. ///
  98. AcDbAssocStatus status() const;
  99. /// <summary>
  100. /// Just a shortcut, calls the method on the parent AcDbAssocDependency that
  101. /// owns this dependency body object.
  102. /// </summary>
  103. ///
  104. Acad::ErrorStatus setStatus(AcDbAssocStatus newStatus,
  105. bool notifyOwningAction = true);
  106. /// <summary>
  107. /// Just a shortcut, calls the method on the parent AcDbAssocDependency that
  108. /// owns this dependency body object.
  109. /// </summary>
  110. ///
  111. AcDbObjectId owningAction() const;
  112. /// <summary>
  113. /// Just a shortcut, calls the method on the parent AcDbAssocDependency that
  114. /// owns this dependency body object.
  115. /// </summary>
  116. ///
  117. AcDbObjectId dependentOnObject() const;
  118. /// <summary>
  119. /// Just a shortcut, calls the method on the parent AcDbAssocDependency that
  120. /// owns this dependency body object.
  121. /// </summary>
  122. ///
  123. bool isAttachedToObject() const { return !dependentOnObject().isNull(); }
  124. /// <summary>
  125. /// Just a shortcut, calls the method on the parent AcDbAssocDependency that
  126. /// owns this dependency body object.
  127. /// </summary>
  128. ///
  129. bool isActionEvaluationInProgress() const;
  130. /// <summary>
  131. /// Just a shortcut, calls the method on the parent AcDbAssocDependency that
  132. /// owns this dependency body object.
  133. /// </summary>
  134. ///
  135. AcDbAssocEvaluationCallback* currentEvaluationCallback() const;
  136. public:
  137. // Virtual methods that can be overridden by the derived classes
  138. /// <summary>
  139. /// Called from the corresponding method of the parent AcDbAssocDependency
  140. /// class that owns this dependency body object. It has to be overridden.
  141. /// </summary>
  142. ///
  143. virtual void evaluateOverride() = 0;
  144. /// <summary>
  145. /// Called from the corresponding method of the parent AcDbAssocDependency
  146. /// class that owns this dependency body object. It does not need to be
  147. /// overridden.
  148. /// </summary>
  149. ///
  150. virtual Acad::ErrorStatus updateDependentOnObjectOverride()
  151. { return Acad::eNotImplemented; }
  152. /// <summary>
  153. /// Called from the corresponding method of the parent AcDbAssocDependency
  154. /// class that owns this dependency body object. It does not need to be
  155. /// overridden.
  156. /// </summary>
  157. ///
  158. virtual Acad::ErrorStatus hasCachedValueOverride(bool& hasCachedVal) const
  159. {
  160. UNREFERENCED_PARAMETER(hasCachedVal);
  161. return Acad::eNotImplemented;
  162. }
  163. /// <summary>
  164. /// Called from the corresponding method of the parent AcDbAssocDependency
  165. /// class that owns this dependency body object. It does not need to be
  166. /// overridden.
  167. /// </summary>
  168. ///
  169. virtual Acad::ErrorStatus isRelevantChangeOverride(bool& isRelevChange) const
  170. {
  171. UNREFERENCED_PARAMETER(isRelevChange);
  172. return Acad::eNotImplemented;
  173. }
  174. /// <summary>
  175. /// Called from the corresponding method of the parent AcDbAssocDependency
  176. /// class that owns this dependency body object. It does not need to be
  177. /// overridden.
  178. /// </summary>
  179. ///
  180. virtual Acad::ErrorStatus isDependentOnTheSameThingAsOverride(const AcDbAssocDependency* pOtherDependency,
  181. bool& isDependentOnSameThing) const
  182. {
  183. UNREFERENCED_PARAMETER(pOtherDependency);
  184. UNREFERENCED_PARAMETER(isDependentOnSameThing);
  185. return Acad::eNotImplemented;
  186. }
  187. /// <summary>
  188. /// Called from the corresponding method of the parent AcDbAssocDependency
  189. /// class that owns this dependency body object. It does not need to be
  190. /// overridden.
  191. /// </summary>
  192. ///
  193. virtual Acad::ErrorStatus isEqualToOverride(const AcDbAssocDependency* pOtherDependency, bool& isEqual) const
  194. {
  195. UNREFERENCED_PARAMETER(pOtherDependency);
  196. UNREFERENCED_PARAMETER(isEqual);
  197. return Acad::eNotImplemented;
  198. }
  199. /// <summary>
  200. /// Called from the corresponding persistent reactor callback method of the
  201. /// parent AcDbAssocDependency class that owns this dependency body object.
  202. /// It does not need to be overridden.
  203. /// </summary>
  204. ///
  205. virtual void erasedOverride(const AcDbObject* pDbObj, Adesk::Boolean isErasing)
  206. {
  207. UNREFERENCED_PARAMETER(pDbObj);
  208. UNREFERENCED_PARAMETER(isErasing);
  209. }
  210. /// <summary>
  211. /// Called from the modified() persistent reactor callback method of the
  212. /// parent AcDbAssocDependency class that owns this dependency body object.
  213. /// It does not need to be overridden.
  214. /// </summary>
  215. ///
  216. virtual void modifiedOverride(const AcDbObject* pDbObj)
  217. {
  218. UNREFERENCED_PARAMETER(pDbObj);
  219. }
  220. /// <summary>
  221. /// Called from the copied() persistent reactor callback method of the
  222. /// parent AcDbAssocDependency class that owns this dependency body object.
  223. /// It does not need to be overridden.
  224. /// </summary>
  225. ///
  226. virtual void clonedOverride(const AcDbObject* pDbObj, const AcDbObject* pNewObj)
  227. {
  228. UNREFERENCED_PARAMETER(pDbObj);
  229. UNREFERENCED_PARAMETER(pNewObj);
  230. }
  231. /// <summary><para>
  232. /// Called from AcDbAssocManager::auditAssociativeData() after file open and possibly
  233. /// after some other scenarios when the associative data may need to be audited and fixed-up.
  234. /// At this time custom code may also initialize internal chaches that were not saved to dwg/dxf
  235. /// file, or do some other work.
  236. /// </para><para>
  237. /// The dependency body may request the parent action to be erased by setting kErasedAssocStatus
  238. /// to parentActionHandling output argument. Setting kChangedDirectlyAssocStatus to
  239. /// parentActionHandling will make the parent action evaluate after the audit of all
  240. /// actions has been completed.
  241. /// </para><para>
  242. /// An example of possible and inevitable inconsistencies is when the drawing was modified
  243. /// in an AutoCAD release that didn't have code for the action, the action body was a proxy
  244. /// and therefore didn't react to notifications and didn't evaluate.
  245. /// </para><para>
  246. /// Another example of possible and inevitable ininconsistencies are references to objects
  247. /// that are not in the database any more because their owning objects were erased, the
  248. /// drawing was then saved, and these objects with erased owners were not saved to
  249. /// database. No notifications happen about the erase of these objects because they were
  250. /// not actually erased, so the actions cannot know that these objects are not in the database
  251. /// any more and may still hold AcDbObjectIds of these "lazily-erased" objects.
  252. /// </para><para>
  253. /// Before auditAssociativeDataOverride() is called, the system performs overall
  254. /// checks and fixes for cases like a dependency depending on a non-existent object,
  255. /// checks proper links between network, action, action body, action parameters, and
  256. /// dependencies, etc., so that these general checks do not need to be performed by
  257. /// the custom code.
  258. /// </para></summary>
  259. ///
  260. virtual void auditAssociativeDataOverride(AcDbAssocStatus& parentActionHandling);
  261. }; // class AcDbAssocDependencyBody
  262. #pragma pack (pop)