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.6 KiB

  1. /***************************************************************************\
  2. *
  3. * File: MsgObject.h
  4. *
  5. * Description:
  6. * MsgObject.h defines the "Message Object" class that is used to receive
  7. * messages in DirectUser. This object is created for each instance of a
  8. * class that is instantiated.
  9. *
  10. *
  11. * History:
  12. * 8/05/2000: JStall: Created
  13. *
  14. * Copyright (C) 2000 by Microsoft Corporation. All rights reserved.
  15. *
  16. \***************************************************************************/
  17. #if !defined(MSG__MsgObject_h__INCLUDED)
  18. #define MSG__MsgObject_h__INCLUDED
  19. #pragma once
  20. class MsgTable;
  21. class MsgClass;
  22. struct ExposedMsgObject
  23. {
  24. const MsgTable * m_pmt;
  25. GArrayS<void *> m_arpThis;
  26. };
  27. class MsgObject : public BaseObject
  28. {
  29. // Construction
  30. public:
  31. inline MsgObject();
  32. inline ~MsgObject();
  33. protected:
  34. virtual void xwDestroy();
  35. void xwEndDestroy();
  36. // BaseObject
  37. public:
  38. virtual HandleType GetHandleType() const { return htMsgObject; }
  39. virtual UINT GetHandleMask() const { return hmMsgObject; }
  40. // Operations
  41. public:
  42. static DUser::Gadget *
  43. CastGadget(HGADGET hgad);
  44. static DUser::Gadget *
  45. CastGadget(MsgObject * pmo);
  46. static HGADGET CastHandle(DUser::Gadget * pg);
  47. static HGADGET CastHandle(MsgObject * pmo);
  48. static MsgObject * CastMsgObject(DUser::Gadget * pg);
  49. static MsgObject * CastMsgObject(HGADGET hgad);
  50. inline DUser::Gadget *
  51. GetGadget() const;
  52. BOOL InstanceOf(const MsgClass * pmcTest) const;
  53. inline DUser::Gadget *
  54. CastClass(const MsgClass * pmcTest) const;
  55. void * GetGutsData(const MsgClass * pmcData) const;
  56. inline HRESULT PreAllocThis(int cSlots);
  57. inline void FillThis(int idxSlotStart, int idxSlotEnd, void * pvThis, const MsgTable * pmtNew);
  58. inline HRESULT Promote(void * pvThis, const MsgTable * pmtNew);
  59. inline void Demote(int cLevels);
  60. inline void * GetThis(int idxThis) const;
  61. inline int GetDepth() const;
  62. inline int GetBuildDepth() const;
  63. inline void InvokeMethod(MethodMsg * pmsg) const;
  64. #if 1
  65. BOOL SetupInternal(HCLASS hcl);
  66. #endif
  67. // Implementation
  68. protected:
  69. static MsgObject * RawCastMsgObject(DUser::Gadget * pg);
  70. static DUser::Gadget *
  71. RawCastGadget(MsgObject * pmo);
  72. public:
  73. static HRESULT CALLBACK
  74. PromoteInternal(DUser::ConstructProc pfnCS, HCLASS hclCur, DUser::Gadget * pgad, DUser::Gadget::ConstructInfo * pciData);
  75. static HCLASS CALLBACK
  76. DemoteInternal(HCLASS hclCur, DUser::Gadget * pgad, void * pvData);
  77. // Data
  78. private:
  79. ExposedMsgObject
  80. m_emo; // Actual data
  81. public:
  82. static HCLASS s_hclSuper; // DUMMY data used by IMPL classes
  83. };
  84. #define DECLARE_INTERNAL(name) \
  85. static HCLASS CALLBACK \
  86. Demote##name(HCLASS hclCur, DUser::Gadget * pgad, void * pvData) \
  87. { \
  88. return DemoteInternal(hclCur, pgad, pvData); \
  89. } \
  90. \
  91. static void MarkInternal() \
  92. { \
  93. GetClassLibrary()->MarkInternal(s_mc.hclNew); \
  94. } \
  95. template <class T>
  96. inline T *
  97. Cast(const MsgObject * pmo)
  98. {
  99. return static_cast<T *> (const_cast<MsgObject *> (pmo)->GetGadget());
  100. }
  101. #include "MsgObject.inl"
  102. #endif // MSG__MsgObject_h__INCLUDED