AcDbAssocPersSubentId.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 March 2007
  12. //
  13. // DESCRIPTION:
  14. //
  15. // AcDbAssocPersSubentId pure virtual base class.
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18. #pragma once
  19. #include "acdb.h"
  20. #pragma pack (push, 8)
  21. /// <summary> <para>
  22. /// Abstract base class used to persistently identify an AcDbSubentId of an
  23. /// AcDbEntity. Unlike AcDbSubentId that is transient and may change when the
  24. /// entity is modified, reevaluated, or similar, the AcDbAssocPersSubentId
  25. /// identifies the subentity in such a way that it is always possible to obtain
  26. /// the corresponding subentities (if they still exist), even after the entity
  27. /// has been edited or reevaluated any number of times.
  28. /// </para> <para>
  29. /// The base AcDbAssocPersSubentId class is an abstract base class. Concrete
  30. /// AcDbEntity classes need their own way how to represent a persistent
  31. /// identitfication of their subentities. Therefore there are derived
  32. /// AcDbAssocPersSubentId classes that keep the persistent identitifcation of
  33. /// the subentities of particular entity types. The simplest one is the
  34. /// AcDbAssocSimplePersSubentId derived class that just keeps the AcDbSubentId
  35. /// in case it can be relied on that it does not change.
  36. /// </para> <para>
  37. /// The AcRx protocol extension classes derived from AcDbAssocPersSubentIdPE
  38. /// base class provide mapping from transient AcDbSubentId to the persistent
  39. /// AcDbAssocPersSubentId, they allow to create new AcDbAssocPersSubentIds from
  40. /// given AcDbSubentIds. The AcDbAssocPersSubentId provides mapping in the
  41. /// opposite direction, from AcDbAssocPersSubentIds to AcDbSubentIds.
  42. /// </para> </summary>
  43. ///
  44. class ACDB_PORT AcDbAssocPersSubentId : public AcRxObject
  45. {
  46. public:
  47. ACRX_DECLARE_MEMBERS(AcDbAssocPersSubentId);
  48. /// <summary> Default constructor. </summary>
  49. AcDbAssocPersSubentId() {}
  50. /// <summary> Virtual destructor. </summary>
  51. virtual ~AcDbAssocPersSubentId() {}
  52. /// <summary><para>
  53. /// The default implementation just calls AcDbAssocPersSubentIdPE::releasePersSubent(),
  54. /// passing the given AcDbEntity* and this AcDbAssocPersSubentId as input arguments.
  55. /// The given AcDbDatabase* argument is ignored.
  56. /// </para><para>
  57. /// The reason for having release() method on AcDbAssocPersSubentId is to be able to
  58. /// release data associated with the AcDbAssocPersSubentId even if the AcDbEntity
  59. /// is no more available and therefore AcDbAssocPersSubentIdPE cannot be obtained
  60. /// and used. Derived AcDbAssocPersSubentId classes may override the release()
  61. /// method to release data associated with the AcDbAssocPersSubentId using the
  62. /// AcDbDatabase* argument. An example is AcDbAssocAsmBasedEntityPersSubentId that
  63. /// needs to know the AcDbDatabase* to obtain the singleton AcDbAssocPersSubentManager
  64. /// object but does not need to know the AcDbEntity*.
  65. /// <param name="pEntity">
  66. /// The entity must be open for write, but usually no changes to the
  67. /// entity will be made (usually no assertWriteEnabled() will be called).
  68. /// </param>
  69. /// <param name="pDatabase">
  70. /// AcDbDatabase of the AcDbEntity that the AcDbAssocPersSubentId references. It is
  71. /// used when the pEntity argument is NULL or the AcDbEntity is not database resident.
  72. /// NULL may be passed for pDatabase if pEntity is not NULL and is a database-resident
  73. /// entity.
  74. /// </param>
  75. /// <returns> Acad::ErrorStatus. </returns>
  76. ///
  77. virtual Acad::ErrorStatus release(AcDbEntity* pEntity, AcDbDatabase* pDatabase) const;
  78. /// <summary> <para>
  79. /// Mapping: AcDbAssocPersSubentId --> AcDbSubentId(s)
  80. /// </para> <para>
  81. /// Obtains all AcDbSubentIds corresponding to this AcDbAssocPersSubentId.
  82. /// </para> </summary>
  83. /// <remarks>
  84. /// Notice that one AcDbAssocPersSubentId may correspond to none, one or more than
  85. /// one AcDbSubentId, because the entity may have changed and there may not be
  86. /// just a single subentity corresponding to the original subentity identified
  87. /// by this AcDbAssocPersSubentId. The default implementation just calls the
  88. /// AcDbAssocPersSubentIdPE::getTransientSubentIds() method.
  89. /// </remarks>
  90. /// <param name="pEntity"> The entity needs to be open for read. </param>
  91. /// <param name="pDatabase">
  92. /// The database that the AcDbAssocPersSubentId belongs to. It may be a different
  93. /// database than the database of the given AcDbEntity when the entity is in an XREF
  94. /// database but the AcDbAssocPersSubentId is owned by an object in the host database.
  95. /// If the database pointer is NULL, the database of the entity is used.
  96. /// </param>
  97. /// <param name="subents"> The returned AcDbSubentIds. </param>
  98. /// <returns> Acad::ErrorStatus. </returns>
  99. ///
  100. virtual Acad::ErrorStatus getTransientSubentIds(const AcDbEntity* pEntity,
  101. AcDbDatabase* pDatabase,
  102. AcArray<AcDbSubentId>& subents) const;
  103. /// <summary> Returns the type of the subentity. </summary>
  104. /// <param name="pEntity"> The entity needs to be open for read. </param>
  105. /// <param name="pDatabase">
  106. /// The database that the AcDbAssocPersSubentId belongs to. It may be a different
  107. /// database than the database of the given AcDbEntity when the entity is in an XREF
  108. /// database but the AcDbAssocPersSubentId is owned by an object in the host database.
  109. /// If the database pointer is NULL, the database of the entity is used.
  110. /// </param>
  111. /// <returns> AcDb::SubentType. </returns>
  112. ///
  113. virtual AcDb::SubentType subentType(const AcDbEntity* pEntity,
  114. AcDbDatabase* pDatabase) const = 0;
  115. /// <summary>
  116. /// Returns the number of transient AcDbSubentIds corresponding to this
  117. /// AcDbAssocPersSubentId. The default implementation just calls
  118. /// getTransientSubentIds() and returns their count which usually is 1.
  119. /// </summary>
  120. /// <param name="pEntity"> The entity needs to be open for read. </param>
  121. /// <param name="pDatabase">
  122. /// The database that the AcDbAssocPersSubentId belongs to. It may be a different
  123. /// database than the database of the given AcDbEntity when the entity is in an XREF
  124. /// database but the AcDbAssocPersSubentId is owned by an object in the host database.
  125. /// If the database pointer is NULL, the database of the entity is used.
  126. /// </param>
  127. /// <returns>
  128. /// Number of transient AcDbSubentIds corresponding to this AcDbAssocPersSubentId.
  129. /// </returns>
  130. ///
  131. virtual int transientSubentCount(const AcDbEntity* pEntity,
  132. AcDbDatabase* pDatabase) const;
  133. /// <summary>
  134. /// Returns true iff this AcDbAssocPersSubentId is null, i.e. not referencing
  135. /// and subentity of any entity. It is logically slightly different from when
  136. /// getTransientSubentIds() returns no AcDbSubentIds. In the latter case the
  137. /// AcDbAssocPersSubentId may reference some subentities, but they may have
  138. /// been deleted, changed, or similar.
  139. /// </summary>
  140. /// <returns> True iff this AcDbAssocPersSubentId is null. </returns>
  141. ///
  142. virtual bool isNull() const = 0;
  143. /// <summary>
  144. /// Returns true iff this and the other AcDbAssocPersSubentId reference
  145. /// exactly the same subentity of the same entity.
  146. /// </summary>
  147. /// <param name="pEntity">
  148. /// The entity owning the subentities of this and the other AcDbAssocPersSubentId.
  149. /// </param>
  150. /// <param name="pDatabase">
  151. /// The database that the AcDbAssocPersSubentId belongs to. It may be a different
  152. /// database than the database of the given AcDbEntity when the entity is in an XREF
  153. /// database but the AcDbAssocPersSubentId is owned by an object in the host database.
  154. /// If the database pointer is NULL, the database of the entity is used.
  155. /// </param>
  156. /// <param name="pOther"> The other AcDbAssocPersSubentId. </param>
  157. /// <returns> True iff this and the other AcDbAssocPersSubentId are equal. </returns>
  158. ///
  159. virtual bool isEqualTo(const AcDbEntity* pEntity,
  160. AcDbDatabase* pDatabase,
  161. const AcDbAssocPersSubentId* pOther) const;
  162. /// <summary> <para>
  163. /// Notifies this AcDbAssocPersSubentId that the entity has been mirrored
  164. /// and that the AcDbAssocPersSubentId may possibly need to update itself
  165. /// to identify the same subentity in the mirrored entity as it identified
  166. /// before the entity has been mirrored.
  167. /// </para> <para>
  168. /// The default implementation obtains AcDbAssocPersSubentIdPE from the
  169. /// mirrored entity and calls AcDbAssocPersSubentIdPE::mirrorPersSubent()
  170. /// that does all the work. By default the "work" is a no-op, except for
  171. /// some entity types, such as AcDbArc and its AcDbAssocArcPersSubentIdPE
  172. /// protocol extension class.
  173. /// </para> </summary>
  174. /// <param name="pMirroredEntity">
  175. /// The entity that has been mirrored. It needs to be open for read.
  176. /// </param>
  177. /// <param name="pDatabase">
  178. /// The database that the AcDbAssocPersSubentId belongs to. It may be a different
  179. /// database than the database of the given AcDbEntity when the entity is in an XREF
  180. /// database but the AcDbAssocPersSubentId is owned by an object in the host database.
  181. /// If the database pointer is NULL, the database of the entity is used.
  182. /// </param>
  183. /// <returns> Acad::ErrorStatus. </returns>
  184. ///
  185. virtual Acad::ErrorStatus mirror(const AcDbEntity* pMirroredEntity,
  186. AcDbDatabase* pDatabase);
  187. /// <summary>
  188. /// A static method that reads the class identification of the actual
  189. /// AcDbAssocPersSubentId-derived class, creates an object of this derived
  190. /// class and calls dwgInFields() on it.
  191. /// </summary>
  192. /// <param name="pDatabase">
  193. /// AcDbDatabase that is going to own the AcDbAssocPersSubentId.
  194. /// </param>
  195. /// <param name="pFiler">
  196. /// The filer to read the data from. The first data is the class identification.
  197. /// </param>
  198. /// <param name="pCreatedPersSubentId">
  199. /// This is an in/out argument used to return the created and filled-in object
  200. /// of an AcDbAssocPersSubentId-derived class. If the pCreatedPersSubentId
  201. /// is passed in as not NULL, the code tries to reuse the existing object,
  202. /// if it is of the expected derived class. If it is passed in as NULL or
  203. /// is not of the expected derived type, it creates a new object (deleting
  204. /// the existing one, if any).
  205. /// /// </param>
  206. /// <returns> Acad::ErrorStatus. </returns>
  207. //
  208. static Acad::ErrorStatus
  209. createObjectAndDwgInFields(AcDbDatabase* pDatabase,
  210. AcDbDwgFiler* pFiler,
  211. AcDbAssocPersSubentId*& pCreatedPersSubentId);
  212. /// <summary>
  213. /// A static method that reads the class identification of the actual
  214. /// AcDbAssocPersSubentId-derived class, creates an object of this derived
  215. /// class and calls dxfInFields() on it.
  216. /// </summary>
  217. /// <param name="pFiler">
  218. /// The filer to read the data from. The first data is the class identification.
  219. /// </param>
  220. /// <param name="pCreatedPersSubentId">
  221. /// This is an in/out argument used to return the created and filled-in object
  222. /// of an AcDbAssocPersSubentId-derived class. If the pCreatedPersSubentId
  223. /// is passed in as not NULL, the code tries to reuse the existing object,
  224. /// if it is of the expected derived class. If it is passed in as NULL or
  225. /// is not of the expected derived type, it creates a new object (deleting
  226. /// the existing one, if any).
  227. /// /// </param>
  228. /// <returns> Acad::ErrorStatus. </returns>
  229. //
  230. static Acad::ErrorStatus
  231. createObjectAndDxfInFields(AcDbDxfFiler* pFiler,
  232. AcDbAssocPersSubentId*& pCreatedPersSubentId);
  233. /// <summary>
  234. /// The standard filing protocol. The AcDbAssocPersSubentId base class
  235. /// implementation writes-out the actual class identification so that
  236. /// it is possible to create an object of the same class when the data is
  237. /// read back in (this happens in createObjectAndDwgInFields()).
  238. /// </summary>
  239. /// <param name="pFiler"> The filer to write the object data to. </param>
  240. /// <returns> Acad::ErrorStatus. </returns>
  241. ///
  242. virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
  243. /// <summary>
  244. /// The standard filing protocol. The AcDbAssocPersSubentId base class
  245. /// implementation does nothing and doesn't therefore need to be called
  246. /// from the derived classes.
  247. /// </summary>
  248. /// <param name="pFiler"> The filer to read the object data from. </param>
  249. /// <returns> Acad::ErrorStatus. </returns>
  250. ///
  251. virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);
  252. /// <summary>
  253. /// The standard filing protocol. The AcDbAssocPersSubentId base class
  254. /// implementation writes-out the actual class identification so that
  255. /// it is possible to create an object of the same class when the data is
  256. /// read back in (this happens in createObjectAndDxfInFields()).
  257. /// </summary>
  258. /// <param name="pFiler"> The filer to write the object data to. </param>
  259. /// <returns> Acad::ErrorStatus. </returns>
  260. ///
  261. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler) const;
  262. /// <summary>
  263. /// The standard filing protocol. The AcDbAssocPersSubentId base class
  264. /// implementation does nothing and doesn't therefore need to be called
  265. /// from the derived classes.
  266. /// </summary>
  267. /// <param name="pFiler"> The filer to read the object data from. </param>
  268. /// <returns> Acad::ErrorStatus. </returns>
  269. ///
  270. virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler);
  271. /// <summary> The standard protocol. </summary>
  272. /// <param name="pAuditInfo"> See the AcDbAuditInfo documentation. </param>
  273. /// <returns> Acad::ErrorStatus. </returns>
  274. ///
  275. virtual Acad::ErrorStatus audit(AcDbAuditInfo* pAuditInfo) {
  276. UNREFERENCED_PARAMETER(pAuditInfo);
  277. return Acad::eOk;
  278. }
  279. /// <summary>Standard protocol for copying of data from source as defined
  280. /// in AcRxObject. Don't use this for cross database copying</summary>
  281. /// <param name="pSource"> Source object to copy data from. </param>
  282. /// <returns> Acad::ErrorStatus. </returns>
  283. ///
  284. virtual Acad::ErrorStatus copyFrom(const AcRxObject* pSource);
  285. }; // class AcDbAssocPersSubentId
  286. #pragma pack (pop)