rxoverrule.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. #ifndef _RXOVERRULE_H
  12. #define _RXOVERRULE_H
  13. #include "acbasedefs.h"
  14. #include "rxobject.h"
  15. #include "acarray.h"
  16. #pragma pack (push, 8)
  17. /// <description>
  18. /// Internal use only. Base class for all overrules.
  19. /// </description>
  20. class AcRxOverruleIteratorBase;
  21. class ADESK_NO_VTABLE AcRxOverruleBase : public AcRxObject
  22. {
  23. public:
  24. ACRX_DECLARE_MEMBERS_EXPIMP(AcRxOverruleBase, ACBASE_PORT);
  25. private:
  26. mutable AcRxOverruleIteratorBase* m_pIter;
  27. friend class AcRxOverruleInternals;
  28. };
  29. /// <property name="versionspecific" value="=18.0.0.0" />
  30. ///
  31. /// <description>
  32. /// AcRxOverrule is an abstract base class for implementing
  33. /// overrules. Overrule providers register and unregister their
  34. /// overrules through addOverrule and removeOverrule. Overrules
  35. /// can be globally activated or deactivated by setIsOverruling.
  36. /// It can also be queried by isOverruleing.
  37. ///
  38. /// Overrules are internally managed by pairs of "targetClass"
  39. /// and "overrule". The "targetClass" is the class that
  40. /// "overrule" is intended to own. Each class can have multiple
  41. /// overrules registered and their order is implied by the order
  42. /// they are registered.
  43. ///
  44. /// Each derived overrule class should provide some or all
  45. /// default implementations that delegate to the default behavior
  46. /// for the targeted class.
  47. /// </description>
  48. #pragma warning( push )
  49. #pragma warning( disable : 4275 )
  50. class ACBASE_PORT AcRxOverrule : public AcRxOverruleBase
  51. {
  52. public:
  53. // --- AcRxObject protocol
  54. ACRX_DECLARE_MEMBERS(AcRxOverrule);
  55. virtual ~AcRxOverrule();
  56. /// <property name="versionspecific" value="=18.0.0.0" />
  57. ///
  58. /// <description>
  59. /// Used to make per-instance determination whether the overrule is applicable.
  60. /// </description>
  61. /// <returns>
  62. /// Returns true if overruling of the overrule should be applied when queried, false otherwise.
  63. /// </returns>
  64. /// <param name="pOverruledSubject">Pointer to an AcRxObject to check.</param>
  65. /// <remarks>
  66. /// If pOverruledSubject is database resident then it is open for read.
  67. /// </remarks>
  68. virtual bool isApplicable(const AcRxObject* pOverruledSubject) const = 0;
  69. /// <property name="versionspecific" value="=18.0.0.0" />
  70. ///
  71. /// <description>
  72. /// Registers an overrule object to an AcRxClass.
  73. /// </description>
  74. /// <param name="pClass">Pointer to an AcRxClass to which "pOverrule" is intended to apply.</param>
  75. /// <param name="pOverrule">Pointer to an AcRxOverrule derived object to overrule.</param>
  76. /// <param name="bAddAtLast">Indicates whether the {pClass, pOverrule} pair should be added at
  77. /// the end of the overrule's collection.</param>
  78. /// <remarks>
  79. /// You should ensure "pOverrule" is appropriate for "pClass". If "pOverrule" can't
  80. /// overrule behaviors in "pClass", then "pOverrule" will have no effect. If more than one
  81. /// overrule specifies bAddAtLast to be true, then their orders will be determined
  82. /// by last in first out.
  83. /// </remarks>
  84. /// <returns>
  85. /// Returns true if the overrule is successfully added.
  86. /// </returns>
  87. static Acad::ErrorStatus addOverrule(AcRxClass* pClass, AcRxOverrule* pOverrule, bool bAddAtLast = false);
  88. /// <property name="versionspecific" value="=18.0.0.0" />
  89. ///
  90. /// <description>
  91. /// Unregister an overrule object from an AcRxClass.
  92. /// </description>
  93. /// <param name="pClass">AcRxClass to which "pOverrule" was applied.</param>
  94. /// <param name="pOverrule">AcRxOverrule derived object to remove.</param>
  95. /// <remarks>
  96. /// The parameters should match the parameters when addOverrule was called.
  97. /// </remarks>
  98. /// <returns>
  99. /// Returns Acad::Ok if the overrule was registered and is now removed from the overrule collection by this call.
  100. /// </returns>
  101. static Acad::ErrorStatus removeOverrule(AcRxClass* pClass, AcRxOverrule* pOverrule);
  102. /// <property name="versionspecific" value="=18.0.0.0" />
  103. ///
  104. /// <description>
  105. /// Globally (application-wise) enable or disable overruling mechanism.
  106. /// </description>
  107. /// <param name="bIsOverruling">True to enable overruling, false to disable.</param>
  108. /// <remarks>
  109. /// Overrule can be turned ON or OFF across the entire application. Does not
  110. /// support per-document enabling or disabling.
  111. /// </remarks>
  112. static void setIsOverruling(bool bIsOverruling);
  113. /// <property name="versionspecific" value="=18.0.0.0" />
  114. ///
  115. /// <description>
  116. /// Queries if the global overruling flag is true or false.
  117. /// </description>
  118. /// <returns>
  119. /// Returns true if overruling is currently turned on, false otherwise.
  120. /// </returns>
  121. static bool isOverruling(void);
  122. /// <property name="versionspecific" value="=18.0.0.0" />
  123. ///
  124. /// <description>
  125. /// Test whether a given object is targeted by a registed overule.
  126. /// </description>
  127. /// <param name="pSubject">AcRxObject to which its type will be examined against all registered overrules of type pOverruleClass.</param>
  128. /// <param name="pOverruleClass">AcRxClass which specifies an overrule class to test.</param>
  129. /// <returns>
  130. /// Returns true if the object is to be handled by the specified overrule. false otherwise.
  131. /// <remarks>
  132. /// Client can test whether there is a given overrule, represented by pOverruleClass,
  133. /// that is interested in overruling the object, pSubject. It returns true if:
  134. /// - The global AcRxOverrule::isOverruling() is turned on;
  135. /// - An overrule (of, or derived from, pOverruleClass) is registered;
  136. /// - The above overrule is targeting objects of pSubject's type.
  137. /// </remarks>
  138. static bool hasOverrule(const AcRxObject* pSubject, AcRxClass* pOverruleClass);
  139. };
  140. /// <property name="versionspecific" value="=19.0.0.0" />
  141. ///
  142. /// <description>
  143. /// AcRxQueryXOverrule overrules the queryX method of AcRxObject
  144. /// </description>
  145. class AcRxQueryXOverrule : public AcRxOverrule
  146. {
  147. public:
  148. ACRX_DECLARE_MEMBERS(AcRxQueryXOverrule);
  149. /// <property name="versionspecific" value="=19.0.0.0" />
  150. ///
  151. /// <description>
  152. /// Default Constructor.
  153. /// </description>
  154. ACBASE_PORT AcRxQueryXOverrule();
  155. /// <property name="versionspecific" value="=19.0.0.0" />
  156. ///
  157. /// <description>
  158. /// Overrules AcRxObject::queryX.
  159. /// </description>
  160. /// <param name="pSubject">Pointer to an AcRxObject that this overrule is applied against.
  161. /// </param>
  162. /// <returns>Returns a protocol extension object associated with this object
  163. /// </returns>
  164. /// <remarks>
  165. /// The default implementation of AcRxQueryXOverrule::queryX calls the
  166. /// protected AcRxObject::subQueryX method.
  167. /// </remarks>
  168. ACBASE_PORT virtual AcRxObject* queryX(const AcRxObject* pSubject, const AcRxClass* protocolClass) const;
  169. };
  170. #pragma warning( pop )
  171. #pragma pack (pop)
  172. #endif // _RXOVERRULE_H