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.

124 lines
3.1 KiB

  1. /***************************************************************************\
  2. *
  3. * File: MsgTable.inl
  4. *
  5. * Description:
  6. * MsgTable.inl implements the "Message Table" object that provide a
  7. * dynamically generated v-table for messages.
  8. *
  9. *
  10. * History:
  11. * 8/05/2000: JStall: Created
  12. *
  13. * Copyright (C) 2000 by Microsoft Corporation. All rights reserved.
  14. *
  15. \***************************************************************************/
  16. #if !defined(MSG__MsgTable_inl__INCLUDED)
  17. #define MSG__MsgTable_inl__INCLUDED
  18. #pragma once
  19. /***************************************************************************\
  20. *****************************************************************************
  21. *
  22. * class MsgTable
  23. *
  24. *****************************************************************************
  25. \***************************************************************************/
  26. //------------------------------------------------------------------------------
  27. inline
  28. MsgTable::MsgTable()
  29. {
  30. }
  31. //------------------------------------------------------------------------------
  32. inline
  33. MsgTable::~MsgTable()
  34. {
  35. }
  36. //------------------------------------------------------------------------------
  37. inline void
  38. MsgTable::Destroy()
  39. {
  40. placement_delete(this, MsgTable);
  41. ProcessFree(this);
  42. }
  43. //------------------------------------------------------------------------------
  44. inline int
  45. MsgTable::GetCount() const
  46. {
  47. return m_cMsgs;
  48. }
  49. //------------------------------------------------------------------------------
  50. inline int
  51. MsgTable::GetDepth() const
  52. {
  53. int cDepth = 0;
  54. const MsgTable * pmt = m_pmtSuper;
  55. while (pmt != NULL) {
  56. cDepth++;
  57. pmt = pmt->m_pmtSuper;
  58. }
  59. return cDepth;
  60. }
  61. //------------------------------------------------------------------------------
  62. inline const MsgClass *
  63. MsgTable::GetClass() const
  64. {
  65. return m_pmcPeer;
  66. }
  67. //------------------------------------------------------------------------------
  68. inline MsgSlot *
  69. MsgTable::GetSlots()
  70. {
  71. BYTE * pb = reinterpret_cast<BYTE *> (this);
  72. pb += sizeof(MsgTable);
  73. return reinterpret_cast<MsgSlot *> (pb);
  74. }
  75. //------------------------------------------------------------------------------
  76. inline const MsgSlot *
  77. MsgTable::GetSlots() const
  78. {
  79. BYTE * pb = reinterpret_cast<BYTE *> (const_cast<MsgTable *> (this));
  80. pb += sizeof(MsgTable);
  81. return reinterpret_cast<const MsgSlot *> (pb);
  82. }
  83. //------------------------------------------------------------------------------
  84. inline const MsgSlot *
  85. MsgTable::GetMsgSlot(
  86. IN int nMsg // Method to invoke
  87. ) const
  88. {
  89. AssertMsg(nMsg < GM_EVENT, "Must be a method");
  90. AssertMsg(nMsg >= sizeof(MsgTable), "Must properly offset from the beginning");
  91. AssertMsg((nMsg - sizeof(MsgTable)) % sizeof(MsgSlot) == 0,
  92. "Must point to the beginning on a slot");
  93. BYTE * pb = reinterpret_cast<BYTE *> (const_cast<MsgTable *> (this));
  94. pb += nMsg;
  95. return reinterpret_cast<const MsgSlot *> (pb);
  96. }
  97. #endif // MSG__MsgTable_inl__INCLUDED