home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / methodcontext.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  3.7 KB  |  128 lines

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