Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
9.4 KiB

  1. /*
  2. * object.h
  3. *
  4. * Copyright (c) 1993 - 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for class Object. This class is the
  8. * base class for every class in the MCS system. It provides the
  9. * behaviors that are common to all classes.
  10. *
  11. * This class only three public member functions. The first is a virtual
  12. * destructor. This destructor does nothing in this class, but it does
  13. * virtualize the destructor for all of its descendants. This allows
  14. * an object to be deleted with a pointer to one of its base classes,
  15. * while guaranteeing that all appropriate destructors get called. This
  16. * means that any object in the system can be deleted with a pointer to
  17. * class Object (this is never really done).
  18. *
  19. * The second member function is a routine that returns the name of the
  20. * class. This allows any object ask another object what the name of
  21. * its class is, regardless what class of pointer the object has. This
  22. * could be used in diagnostics, for example.
  23. *
  24. * The last common behavior is by far the most important. This class
  25. * defines a virtual function called OwnerCallback. Since all classes
  26. * in MCS inherit from this class, that means that any object in the
  27. * system can potentially receive and process an OwnerCallback call.
  28. *
  29. * Owner callbacks are used when it is necessary for an object to send
  30. * messages to any object for which it doesn't know the public interface.
  31. * This is most commonly the object that created it (the owner). A good
  32. * example of its use is this. Object A creates object B. Object B
  33. * performs some operations in the system, and then determines that its
  34. * work is through. It needs to be deleted, but only object A can do that
  35. * since it holds the reference to B (unless it has been passed to someone
  36. * else). Owner callbacks allows object B to send a message to object A
  37. * asking to be deleted. Class B does not have to know the public
  38. * interface of class A for this to work. It only has to know that class A
  39. * inherits from class Object.
  40. *
  41. * When a class needs to be able to send owner callbacks, these callbacks
  42. * become part of the interface of the class. In this way, these
  43. * interfaces are really bi-directional. They contain a class definition
  44. * which defines what messages can be sent to an object of that class.
  45. * The owner callbacks defined in the interface file show what messages
  46. * can be sent from instances of the class. When a decision is made for
  47. * one class to use another, the using class needs to accept responsibility
  48. * for handling any owner callbacks that the used class can generate.
  49. *
  50. * When any class uses a class that can generate owner callbacks, the
  51. * using class should override the OwnerCallback member function defined
  52. * here. Failure to handle owner callbacks that are issued by a child
  53. * object is a serious design flaw.
  54. *
  55. * This class contains a default implementation of the OwnerCallback
  56. * member function. This default implmentation merely prints an error
  57. * reporting an unhandled owner callback.
  58. *
  59. * The exact mechanics behind how the owner callbacks work is discussed
  60. * below in the definition of the default handler.
  61. *
  62. * Caveats:
  63. * None.
  64. *
  65. * Author:
  66. * James P. Galvin, Jr.
  67. */
  68. #ifndef _OBJECT2_H_
  69. #define _OBJECT2_H_
  70. /*
  71. * This is the class definition of class Object.
  72. */
  73. class IObject
  74. {
  75. public:
  76. virtual ~IObject(void) = 0;
  77. virtual ULONG OwnerCallback(ULONG message,
  78. void *parameter1 = NULL,
  79. void *parameter2 = NULL,
  80. void *parameter3 = NULL)
  81. {
  82. ERROR_OUT(("IObject::OwnerCallback: unattended owner callback"));
  83. return 0;
  84. };
  85. };
  86. /*
  87. * virtual ~Object ()
  88. *
  89. * Functional Description:
  90. * This is Object class destructor. It does nothing. Its purpose is to
  91. * virtualize the destructor for all derived classes. This insures that
  92. * when an object is deleted, all proper destructors get executed.
  93. *
  94. * Formal Parameters:
  95. * None.
  96. *
  97. * Return Value:
  98. * None.
  99. *
  100. * Side Effects:
  101. * None.
  102. *
  103. * Caveats:
  104. * None.
  105. */
  106. /*
  107. * ULong OwnerCallback (
  108. * UShort message,
  109. * PVoid parameter1,
  110. * ULong parameter2)
  111. *
  112. * Functional Description:
  113. * This is the default implementation of the owner callback function.
  114. * It does nothing except to report that an owner callback was not
  115. * properly handled. This should be seen as a very serious error.
  116. * When any class expects to receive owner callbacks, it should override
  117. * this function, and provide real behavior.
  118. *
  119. * Formal Parameters:
  120. * message
  121. * This is the message to processed. The messages that are valid are
  122. * defined as part of the public interface of the class that is
  123. * issuing the owner callbacks. These messages normally range from
  124. * 0 to N-1 where N is the number of valid callbacks defined. Note
  125. * that when a class needs to be able to issue owner callbacks, it
  126. * is given two parameters defining the recipient. The first is a
  127. * pointer to the object (POwnerObject, typedefed above). The
  128. * second is an owner message base. This is an offset that the
  129. * sending class adds to each message that it sends. This allows
  130. * one class to be the recipient of owner callbacks from more than
  131. * one class without the messages stepping on one another. The message
  132. * base is simply set to be different for each child class.
  133. * parameter1
  134. * parameter2
  135. * These parameters vary in meaning according to the message being
  136. * processed. The meaning of the parameters is defined in the
  137. * interface file of the class issuing the callback.
  138. *
  139. * Return Value:
  140. * This is a 32-bit value whose meaning varies acording to the message
  141. * being processed. As with the parameters above, the meaning of the
  142. * return value is defined in the interface file of the class that is
  143. * issuing the callback.
  144. *
  145. * Side Effects:
  146. * None.
  147. *
  148. * Caveats:
  149. * None.
  150. */
  151. /*
  152. * ULong OwnerCallback (
  153. * UShort message,
  154. * ULong parameter1,
  155. * ULong parameter2,
  156. * PVoid parameter3)
  157. *
  158. * Functional Description:
  159. * This is the default implementation of the owner callback function.
  160. * It does nothing except to report that an owner callback was not
  161. * properly handled. This should be seen as a very serious error.
  162. * When any class expects to receive owner callbacks, it should override
  163. * this function, and provide real behavior.
  164. *
  165. * This function has 4 total parameters. It differs from the other
  166. * OwnerCallback function by the number of parameters it takes. This
  167. * alternative function was added because the other OwnerCallback()
  168. * function did not allow enough parameter space. Usually, in a project
  169. * you will decide to use either this OwnerCallback() or the other, but
  170. * not both.
  171. *
  172. * Formal Parameters:
  173. * message
  174. * This is the message to processed. The messages that are valid are
  175. * defined as part of the public interface of the class that is
  176. * issuing the owner callbacks. These messages normally range from
  177. * 0 to N-1 where N is the number of valid callbacks defined. Note
  178. * that when a class needs to be able to issue owner callbacks, it
  179. * is given two parameters defining the recipient. The first is a
  180. * pointer to the object (POwnerObject, typedefed above). The
  181. * second is an owner message base. This is an offset that the
  182. * sending class adds to each message that it sends. This allows
  183. * one class to be the recipient of owner callbacks from more than
  184. * one class without the messages stepping on one another. The message
  185. * base is simply set to be different for each child class.
  186. * parameter1
  187. * parameter2
  188. * parameter3
  189. * These parameters vary in meaning according to the message being
  190. * processed. The meaning of the parameters is defined in the
  191. * interface file of the class issuing the callback.
  192. *
  193. * Return Value:
  194. * This is a 32-bit value whose meaning varies acording to the message
  195. * being processed. As with the parameters above, the meaning of the
  196. * return value is defined in the interface file of the class that is
  197. * issuing the callback.
  198. *
  199. * Side Effects:
  200. * None.
  201. *
  202. * Caveats:
  203. * None.
  204. */
  205. #endif