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.

144 lines
4.2 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright � Microsoft Corporation. All rights reserved.
  4. //
  5. // MethodCo.h
  6. //
  7. // Purpose: declaration of MethodContext class
  8. //
  9. //***************************************************************************
  10. #if _MSC_VER > 1000
  11. #pragma once
  12. #endif
  13. #ifndef _METHOD_CONTEXT_H__
  14. #define _METHOD_CONTEXT_H__
  15. //#include "ThrdBase.h"
  16. //#include "refptrco.h"
  17. #ifdef PROVIDER_INSTRUMENTATION
  18. #include <stopwatch.h>
  19. #endif
  20. class CInstance;
  21. class Provider;
  22. class MethodContext;
  23. class CWbemProviderGlue;
  24. class InternalMethodContextAsynch;
  25. typedef HRESULT (WINAPI *LPProviderInstanceCallback)(Provider *pProvider, CInstance *pInstance, MethodContext *pContext, void *pUserData);
  26. //////////////////////////////////////////////////////
  27. //
  28. // STRUCT MethodContext
  29. //
  30. // a little something to make sure we can keep our threads from getting tangled
  31. // idea is that there is one MethodContext for each request from CIMOM or another provider
  32. // pointers are passed around.
  33. //////////////////////////////////////////////////////
  34. class POLARITY MethodContext : public CThreadBase
  35. {
  36. public:
  37. friend InternalMethodContextAsynch;
  38. friend CWbemProviderGlue;
  39. MethodContext(IWbemContext __RPC_FAR *piContext, CWbemProviderGlue *pGlue);
  40. ~MethodContext();
  41. virtual HRESULT Commit(CInstance *pInstance) = 0;
  42. virtual IWbemContext __RPC_FAR *GetIWBEMContext();
  43. LONG AddRef(void);
  44. LONG Release(void);
  45. virtual void QueryPostProcess(void);
  46. bool SetStatusObject(IWbemClassObject *pObj);
  47. IWbemClassObject __RPC_FAR *GetStatusObject();
  48. #ifdef PROVIDER_INSTRUMENTATION
  49. StopWatch *pStopWatch;
  50. #endif
  51. private:
  52. CWbemProviderGlue* GetProviderGlue();
  53. CWbemProviderGlue *m_pGlue;
  54. IWbemContext __RPC_FAR *m_pContext;
  55. IWbemClassObject __RPC_FAR *m_pStatusObject;
  56. };
  57. // for queries and suchlike that originate in CIMOM
  58. class
  59. __declspec(uuid("9113D3B4-D114-11d2-B35D-00104BC97924"))
  60. ExternalMethodContext : public MethodContext
  61. {
  62. public:
  63. ExternalMethodContext(IWbemObjectSink __RPC_FAR *pResponseHandler,
  64. IWbemContext __RPC_FAR *pContext,
  65. CWbemProviderGlue *pGlue,
  66. void *pReserved = NULL
  67. );
  68. HRESULT Commit(CInstance *pInstance);
  69. virtual void QueryPostProcess(void);
  70. LONG AddRef(void);
  71. LONG Release(void);
  72. private:
  73. IWbemObjectSink __RPC_FAR *m_pResponseHandler;
  74. void *m_pReserved;
  75. };
  76. // for queries and suchlike that come from within.
  77. // contains a list of objects returned.
  78. class
  79. __declspec(uuid("6AF4B074-D121-11d2-B35D-00104BC97924"))
  80. InternalMethodContext : public MethodContext
  81. {
  82. public:
  83. InternalMethodContext(TRefPointerCollection<CInstance> *pList ,
  84. IWbemContext __RPC_FAR *pContext,
  85. CWbemProviderGlue *pGlue);
  86. ~InternalMethodContext();
  87. HRESULT Commit(CInstance *pInstance);
  88. LONG AddRef(void);
  89. LONG Release(void);
  90. private:
  91. TRefPointerCollection<CInstance> *m_pInstances;
  92. };
  93. // for queries and suchlike that come from within.
  94. // "Asynch" is a bit of a misnomer - but it does help support
  95. // asynchronous calls, in that each instance committed is routed
  96. // to a callback function supplied by the requester
  97. class
  98. __declspec(uuid("D98A82E8-D121-11d2-B35D-00104BC97924"))
  99. InternalMethodContextAsynch : public MethodContext
  100. {
  101. public:
  102. InternalMethodContextAsynch(Provider *pThat,
  103. LPProviderInstanceCallback pCallback,
  104. IWbemContext __RPC_FAR *pContext,
  105. MethodContext *pUsersContext,
  106. void *pUserData);
  107. ~InternalMethodContextAsynch();
  108. HRESULT Commit(CInstance *pInstance);
  109. LONG AddRef(void);
  110. LONG Release(void);
  111. private:
  112. Provider *m_pThat;
  113. LPProviderInstanceCallback m_pCallback;
  114. void *m_pUserData;
  115. MethodContext *m_pUsersContext;
  116. };
  117. #endif