dbObjectContextInterface.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. //
  12. // dbObjectContextInterface.h
  13. //
  14. // DESCRIPTION: Protocol extension base class
  15. // AcDbObjectContextInterface
  16. //
  17. #pragma once
  18. #pragma pack (push, 8)
  19. #include "acdb.h"
  20. #include "dbmain.h"
  21. class AcDbObjectContext;
  22. const ACDB_PORT AcString& acdbAnnotationScaleCollectionName();
  23. ////////////////////////////////////////////////////////////////////////
  24. // class AcDbObjectContextInterface
  25. ////////////////////////////////////////////////////////////////////////
  26. /// <summary>
  27. /// Abstract protocol extension interface class which allows supporting
  28. /// context-specific behavior on an object.
  29. /// </summary>
  30. ///
  31. /// <remarks>
  32. /// Custom objects provide an implementation of this interface and associate
  33. /// with their AcRxClass to provide context-dependent object behavior. One
  34. /// example of such behavior is annotation scalin where the context is the
  35. /// current viewport scale, and where the custom object behavior for text is
  36. /// the text height, orientation, and position. Applications can define other
  37. /// context types (AcDbObjectContext custom classes), store them in custom
  38. /// collections (AcDbObjectContextCollection). By implementing this interface,
  39. /// custom objects expose information about which context types they support
  40. /// and when context instances they participate in.
  41. /// </remarks>
  42. ///
  43. class AcDbObjectContextInterface : public AcRxObject
  44. {
  45. public:
  46. ACRX_DECLARE_MEMBERS(AcDbObjectContextInterface);
  47. /// <summary>
  48. /// Determines if a particular context type is supported by the object.
  49. /// </summary>
  50. ///
  51. /// <param name="pObject">
  52. /// The object supporting the collection.
  53. /// </param>
  54. ///
  55. /// <param name="collectionName">
  56. /// The name of the collection (context type) to test for support.
  57. /// </param>
  58. ///
  59. /// <returns>
  60. /// Returns "true" if the object supports context types with the specified
  61. /// name.
  62. /// </returns>
  63. ///
  64. /// <remarks>
  65. /// Whether an object supports a collection type is different from whether
  66. /// the object currently participates in any contexts of that type. See
  67. /// also the hasContext() method.
  68. /// </remarks>
  69. virtual bool supportsCollection (
  70. const AcDbObject* pObject,
  71. const AcString& collectionName ) const = 0;
  72. /// <summary>
  73. /// Determines if an object is currently active in a partuclar context.
  74. /// </summary>
  75. ///
  76. /// <param name="pObject">
  77. /// A pointer to an object supporting object contexts.
  78. /// </param>
  79. ///
  80. /// <param name="context">
  81. /// The context to test.
  82. /// </param>
  83. ///
  84. /// <returns>
  85. /// Returns true if the object supports the context type and is currently
  86. /// active in the specified context instance.
  87. /// </returns>
  88. virtual bool hasContext ( const AcDbObject* pObject,
  89. const AcDbObjectContext& context ) const = 0;
  90. /// <summary>
  91. /// Adds a context to the list of active contexts for an object.
  92. /// </summary>
  93. ///
  94. /// <param name="pObject">
  95. /// A pointer to the object to make active in the context.
  96. /// </param>
  97. ///
  98. /// <param name="context">
  99. /// The context to make active for the object.
  100. /// </param>
  101. ///
  102. /// <returns>
  103. /// Returns Acad::eOk if successful. Returns Acad::eInvalidInput if the
  104. /// object does not support the context type. Returns
  105. /// Acad::eDuplicateRecordName if a context with the specified name already
  106. /// exists.
  107. /// </returns>
  108. ///
  109. virtual Acad::ErrorStatus addContext (
  110. AcDbObject* pObject,
  111. const AcDbObjectContext& context ) const = 0;
  112. /// <summary>
  113. /// Removes a contextfrom the list of active contexts for an object.
  114. /// </summary>
  115. ///
  116. /// <param name="pObject">
  117. /// A pointer to the object to remove the context from.
  118. /// </param>
  119. ///
  120. /// <param name="context">
  121. /// The context to remove from the object.
  122. /// </param>
  123. ///
  124. /// <returns>
  125. /// Returns Acad::eOk if successful. Returns Acad::eInvalidInput if the
  126. /// object does not support the context type.
  127. /// </returns>
  128. ///
  129. virtual Acad::ErrorStatus removeContext (
  130. AcDbObject* pObject,
  131. const AcDbObjectContext& context ) const = 0;
  132. };
  133. #pragma pack (pop)