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.

220 lines
5.0 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 "package.h"
  15. #include "asptlb.h" // needed to define interface pointers
  16. #include "memcls.h"
  17. class CHitObj; // forward decl
  18. /*===================================================================
  19. Transaction Support Types
  20. ===================================================================*/
  21. #define TransType DWORD
  22. #define ttUndefined 0x00000000
  23. #define ttNotSupported 0x00000001
  24. #define ttSupported 0x00000002
  25. #define ttRequired 0x00000004
  26. #define ttRequiresNew 0x00000008
  27. /*===================================================================
  28. CViperAsyncRequest class implements IMTSCall interface.
  29. Its OnCall() method does HitObj processing.
  30. This is a private class used in CViperActivity class
  31. ===================================================================*/
  32. class CViperAsyncRequest : public IMTSCall
  33. {
  34. private:
  35. DWORD m_cRefs; // reference count
  36. CHitObj *m_pHitObj; // request
  37. private:
  38. CViperAsyncRequest();
  39. ~CViperAsyncRequest();
  40. HRESULT Init(CHitObj *pHitObj);
  41. public:
  42. #ifdef DBG
  43. virtual void AssertValid() const;
  44. #else
  45. virtual void AssertValid() const {}
  46. #endif
  47. public:
  48. // IUnknown Methods
  49. STDMETHODIMP QueryInterface(REFIID iid, void **ppv);
  50. STDMETHODIMP_(ULONG) AddRef();
  51. STDMETHODIMP_(ULONG) Release();
  52. // IMTSCall Method
  53. STDMETHODIMP OnCall();
  54. friend class CViperActivity;
  55. // Cache on per-class basis
  56. ACACHE_INCLASS_DEFINITIONS()
  57. };
  58. extern volatile LONG g_nViperRequests;
  59. #ifdef UNUSED
  60. /*===================================================================
  61. CViperThreadEvents class implements IThreadEvents interface.
  62. It allows us to do work on each thread that Viper starts up in their
  63. threadpool.
  64. ===================================================================*/
  65. class CViperThreadEvents : public IThreadEvents
  66. {
  67. private:
  68. DWORD m_cRefs; // reference count
  69. public:
  70. CViperThreadEvents();
  71. ~CViperThreadEvents() {};
  72. public:
  73. // IUnknown Methods
  74. STDMETHODIMP QueryInterface(REFIID iid, void **ppv);
  75. STDMETHODIMP_(ULONG) AddRef();
  76. STDMETHODIMP_(ULONG) Release();
  77. // IThreadEvents Method
  78. STDMETHODIMP OnStartup();
  79. STDMETHODIMP OnShutdown();
  80. private:
  81. #ifdef DBG
  82. virtual void AssertValid() const;
  83. #else
  84. virtual void AssertValid() const {}
  85. #endif
  86. };
  87. #endif //UNUSED
  88. /*===================================================================
  89. CViperActivity corresponds to a Session.
  90. It creates MTS activity, and launches async requests
  91. ===================================================================*/
  92. class CViperActivity
  93. {
  94. private:
  95. IMTSActivity *m_pActivity;
  96. DWORD m_cBind; // inited-flag + bind-to-thread count
  97. inline BOOL FInited() const { return (m_cBind > 0); }
  98. public:
  99. CViperActivity();
  100. ~CViperActivity();
  101. // Create Viper activity
  102. HRESULT Init(BOOL fCreateInMTA = FALSE);
  103. // Clone Viper activity
  104. HRESULT InitClone(CViperActivity *pActivity);
  105. // Bind/Unbind
  106. HRESULT BindToThread();
  107. HRESULT UnBindFromThread();
  108. // Release Viper activity
  109. HRESULT UnInit();
  110. // Check if thread-bound
  111. inline BOOL FThreadBound() const { return (m_cBind > 1); }
  112. // Post async request within this activity
  113. HRESULT PostAsyncRequest(CHitObj *pHitObj);
  114. // post async request without an activity
  115. static HRESULT PostGlobalAsyncRequest(CHitObj *pHitObj);
  116. public:
  117. #ifdef DBG
  118. virtual void AssertValid() const;
  119. #else
  120. virtual void AssertValid() const {}
  121. #endif
  122. // Cache on per-class basis
  123. ACACHE_INCLASS_DEFINITIONS()
  124. };
  125. /*===================================================================
  126. Misc. Functions
  127. ===================================================================*/
  128. HRESULT ViperAttachIntrinsicsToContext
  129. (
  130. IApplicationObject *pAppln,
  131. ISessionObject *pSession = NULL,
  132. IRequest *pRequest = NULL,
  133. IResponse *pResponse = NULL,
  134. IServer *pServer = NULL
  135. );
  136. HRESULT ViperGetObjectFromContext
  137. (
  138. BSTR bstrName,
  139. IDispatch **ppdisp
  140. );
  141. HRESULT ViperGetHitObjFromContext
  142. (
  143. CHitObj **ppHitObj
  144. );
  145. HRESULT ViperCreateInstance
  146. (
  147. REFCLSID rclsid,
  148. REFIID riid,
  149. void **ppv
  150. );
  151. HRESULT ViperConfigure(DWORD cThreads, BOOL fAllowOopComponents);
  152. #ifdef UNUSED
  153. HRESULT SetViperThreadEvents();
  154. #endif //UNUSED
  155. /*===================================================================
  156. COM Helper API
  157. ===================================================================*/
  158. BOOL ViperCoObjectIsaProxy
  159. (
  160. IUnknown *pUnk
  161. );
  162. BOOL ViperCoObjectAggregatesFTM
  163. (
  164. IUnknown *pUnk
  165. );
  166. #endif // VIPERINT