Source code of Windows XP (NT5)
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.

192 lines
4.4 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1997 Microsoft Corporation. All Rights Reserved.
  5. Component: Viper Integration Objects
  6. File: viperint.h
  7. Owner: DmitryR
  8. This file contains the definiton of viper integration classes
  9. ===================================================================*/
  10. #ifndef VIPERINT_H
  11. #define VIPERINT_H
  12. #include "mtx.h"
  13. #include "mtxpriv.h"
  14. #include "comsvcs.h"
  15. #include "package.h"
  16. #include "asptlb.h" // needed to define interface pointers
  17. #include "memcls.h"
  18. class CHitObj; // forward decl
  19. /*===================================================================
  20. Transaction Support Types
  21. ===================================================================*/
  22. #define TransType DWORD
  23. #define ttUndefined 0x00000000
  24. #define ttNotSupported 0x00000001
  25. #define ttSupported 0x00000002
  26. #define ttRequired 0x00000004
  27. #define ttRequiresNew 0x00000008
  28. /*===================================================================
  29. CViperAsyncRequest class implements IMTSCall interface.
  30. Its OnCall() method does HitObj processing.
  31. This is a private class used in CViperActivity class
  32. ===================================================================*/
  33. class CViperAsyncRequest : public IServiceCall, public IAsyncErrorNotify
  34. {
  35. private:
  36. DWORD m_cRefs; // reference count
  37. CHitObj *m_pHitObj; // request
  38. IServiceActivity *m_pActivity;
  39. HRESULT m_hrOnError;
  40. DWORD m_dwRepostAttempts;
  41. private:
  42. CViperAsyncRequest();
  43. ~CViperAsyncRequest();
  44. HRESULT Init(CHitObj *pHitObj, IServiceActivity *pActivity);
  45. public:
  46. #ifdef DBG
  47. virtual void AssertValid() const;
  48. #else
  49. virtual void AssertValid() const {}
  50. #endif
  51. public:
  52. // IUnknown Methods
  53. STDMETHODIMP QueryInterface(REFIID iid, void **ppv);
  54. STDMETHODIMP_(ULONG) AddRef();
  55. STDMETHODIMP_(ULONG) Release();
  56. // IServiceCall Method
  57. STDMETHODIMP OnCall();
  58. // IAsyncErrorNotify
  59. STDMETHODIMP OnError(HRESULT hr);
  60. friend class CViperActivity;
  61. // Cache on per-class basis
  62. ACACHE_INCLASS_DEFINITIONS()
  63. };
  64. extern volatile LONG g_nViperRequests;
  65. /*===================================================================
  66. CViperActivity corresponds to a Session.
  67. It creates MTS activity, and launches async requests
  68. ===================================================================*/
  69. class CViperActivity
  70. {
  71. private:
  72. IServiceActivity *m_pActivity;
  73. DWORD m_cBind; // inited-flag + bind-to-thread count
  74. inline BOOL FInited() const { return (m_cBind > 0); }
  75. public:
  76. CViperActivity();
  77. ~CViperActivity();
  78. // Create Viper activity
  79. HRESULT Init(IUnknown *pConfig);
  80. // Clone Viper activity
  81. HRESULT InitClone(CViperActivity *pActivity);
  82. // Bind/Unbind
  83. HRESULT BindToThread();
  84. HRESULT UnBindFromThread();
  85. // Release Viper activity
  86. HRESULT UnInit();
  87. // Check if thread-bound
  88. inline BOOL FThreadBound() const { return (m_cBind > 1); }
  89. // Post async request within this activity
  90. HRESULT PostAsyncRequest(CHitObj *pHitObj);
  91. // post async request without an activity
  92. static HRESULT PostGlobalAsyncRequest(CHitObj *pHitObj);
  93. public:
  94. #ifdef DBG
  95. virtual void AssertValid() const;
  96. #else
  97. virtual void AssertValid() const {}
  98. #endif
  99. // Cache on per-class basis
  100. ACACHE_INCLASS_DEFINITIONS()
  101. };
  102. /*===================================================================
  103. Misc. Functions
  104. ===================================================================*/
  105. HRESULT ViperAttachIntrinsicsToContext
  106. (
  107. IApplicationObject *pAppln,
  108. ISessionObject *pSession = NULL,
  109. IRequest *pRequest = NULL,
  110. IResponse *pResponse = NULL,
  111. IServer *pServer = NULL
  112. );
  113. HRESULT ViperGetObjectFromContext
  114. (
  115. BSTR bstrName,
  116. IDispatch **ppdisp
  117. );
  118. HRESULT ViperGetHitObjFromContext
  119. (
  120. CHitObj **ppHitObj
  121. );
  122. HRESULT ViperCreateInstance
  123. (
  124. REFCLSID rclsid,
  125. REFIID riid,
  126. void **ppv
  127. );
  128. HRESULT ViperConfigure(DWORD cThreads, BOOL fAllowOopComponents);
  129. #ifdef UNUSED
  130. HRESULT SetViperThreadEvents();
  131. #endif //UNUSED
  132. /*===================================================================
  133. COM Helper API
  134. ===================================================================*/
  135. BOOL ViperCoObjectIsaProxy
  136. (
  137. IUnknown *pUnk
  138. );
  139. BOOL ViperCoObjectAggregatesFTM
  140. (
  141. IUnknown *pUnk
  142. );
  143. #endif // VIPERINT