home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / common / msdev98 / template / atl / asp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-16  |  3.7 KB  |  151 lines

  1. [!if=(FreeThreadedMarshaler, "TRUE")]
  2.     [!set(NeedsGetControllingUnknown, "TRUE")]
  3. [!endif]
  4. // [!HeaderName] : Declaration of the [!ClassName]
  5. [!crlf]
  6.  
  7. [!if=(FileExists, "FALSE")]
  8. #ifndef __[!UpperShortName]_H_
  9. #define __[!UpperShortName]_H_
  10. [!crlf]
  11. #include "resource.h"       // main symbols
  12. #include <asptlb.h>         // Active Server Pages Definitions
  13. [!else]
  14. [!AddIncludeFile(TargetFile, "resource.h")]
  15. [!AddIncludeFile(TargetFile, "<asptlb.h>")]
  16. [!endif]
  17. [!crlf]
  18. /////////////////////////////////////////////////////////////////////////////
  19. // [!ClassName]
  20.  
  21. class ATL_NO_VTABLE [!ClassName] : 
  22. [!if=(ThreadingModel, "Single")]
  23.     public CComObjectRootEx<CComSingleThreadModel>,
  24. [!endif]
  25. [!if=(ThreadingModel, "Apartment")]
  26.     public CComObjectRootEx<CComSingleThreadModel>,
  27. [!endif]
  28. [!if=(ThreadingModel, "Both")]
  29.     public CComObjectRootEx<CComMultiThreadModel>,
  30. [!endif]
  31. [!if=(ThreadingModel, "Free")]
  32.     public CComObjectRootEx<CComMultiThreadModel>,
  33. [!endif]
  34.     public CComCoClass<[!ClassName], &CLSID_[!CoClassName]>,
  35. [!if=(ErrorInfoEnabled, "TRUE")]
  36.     public ISupportErrorInfo,
  37. [!endif]
  38. [!if=(ConnectionPointsEnabled, "TRUE")]
  39.     public IConnectionPointContainerImpl<[!ClassName]>,
  40. [!endif]
  41. [!if=(Dual, "TRUE")]
  42.     public IDispatchImpl<[!InterfaceName], &IID_[!InterfaceName], &LIBID_[!LibName]>
  43. [!else]
  44.     public [!InterfaceName]
  45. [!endif]
  46. {
  47. public:
  48.     [!ClassName]()
  49.     { 
  50. [!if=(FreeThreadedMarshaler, "TRUE")]        m_pUnkMarshaler = NULL;[!endif]
  51. [!if=(OnStartPage, "TRUE")]        m_bOnStartPageCalled = FALSE;[!endif]
  52.     }
  53. [!crlf]
  54. public:
  55. [!crlf]
  56. DECLARE_REGISTRY_RESOURCEID([!IDR_REGISTRYID])
  57. [!crlf]
  58. DECLARE_PROTECT_FINAL_CONSTRUCT()
  59.  
  60. [!if=(Aggregatable, "NO")]
  61. DECLARE_NOT_AGGREGATABLE([!ClassName])
  62. [!endif]
  63. [!if=(Aggregatable, "ONLY")]
  64. DECLARE_ONLY_AGGREGATABLE([!ClassName])
  65. [!endif]
  66.  
  67. [!if=(NeedsGetControllingUnknown, "TRUE")]
  68. DECLARE_GET_CONTROLLING_UNKNOWN()
  69. [!endif]
  70.  
  71. [!crlf]
  72. BEGIN_COM_MAP([!ClassName])
  73.     COM_INTERFACE_ENTRY([!InterfaceName])
  74. [!if=(Dual, "TRUE")]
  75.     COM_INTERFACE_ENTRY(IDispatch)
  76. [!endif]
  77. [!if=(ErrorInfoEnabled, "TRUE")]
  78.     COM_INTERFACE_ENTRY(ISupportErrorInfo)
  79. [!endif]
  80. [!if=(ConnectionPointsEnabled, "TRUE")]
  81.     COM_INTERFACE_ENTRY(IConnectionPointContainer)
  82. [!endif]
  83. [!if=(FreeThreadedMarshaler, "TRUE")]
  84.     COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  85. [!endif]
  86. END_COM_MAP()
  87.  
  88. [!if=(ConnectionPointsEnabled, "TRUE")]
  89. [!crlf]
  90. BEGIN_CONNECTION_POINT_MAP([!ClassName])
  91. END_CONNECTION_POINT_MAP()
  92. [!crlf]
  93. [!endif]
  94.  
  95. [!if=(FreeThreadedMarshaler, "TRUE")]
  96. [!crlf]
  97.     HRESULT FinalConstruct()
  98.     {
  99.         return CoCreateFreeThreadedMarshaler(
  100.             GetControllingUnknown(), &m_pUnkMarshaler.p);
  101.     }
  102.  
  103. [!crlf]
  104.     void FinalRelease()
  105.     {
  106.         m_pUnkMarshaler.Release();
  107.     }
  108.  
  109. [!crlf]
  110.     CComPtr<IUnknown> m_pUnkMarshaler;
  111. [!endif]
  112.  
  113. [!if=(ErrorInfoEnabled, "TRUE")]
  114. [!crlf]
  115. // ISupportsErrorInfo
  116.     STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  117. [!endif]
  118.  
  119. [!crlf]
  120. // [!InterfaceName]
  121. public:
  122. [!if=(OnStartPage, "TRUE")]
  123.     //Active Server Pages Methods
  124.     STDMETHOD(OnStartPage)(IUnknown* IUnk);
  125.     STDMETHOD(OnEndPage)();
  126. [!crlf]
  127. private:
  128. [!if=(Request, "TRUE")]
  129.     CComPtr<IRequest> m_piRequest;                    //Request Object
  130. [!endif]
  131. [!if=(Response, "TRUE")]
  132.     CComPtr<IResponse> m_piResponse;                //Response Object
  133. [!endif]
  134. [!if=(Session, "TRUE")]
  135.     CComPtr<ISessionObject> m_piSession;            //Session Object
  136. [!endif]
  137. [!if=(Server, "TRUE")]
  138.     CComPtr<IServer> m_piServer;                    //Server Object
  139. [!endif]
  140. [!if=(Application, "TRUE")]
  141.     CComPtr<IApplicationObject> m_piApplication;    //Application Object
  142. [!endif]
  143.     BOOL m_bOnStartPageCalled;                        //OnStartPage successful?
  144. [!endif]
  145. };
  146.  
  147. [!crlf]
  148. [!if=(FileExists, "FALSE")]
  149. #endif //__[!UpperShortName]_H_
  150. [!endif]
  151.