home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Internet 2000 May / MICD_2000_05.iso / CBuilder5 / INSTALL / DATA1.CAB / Program_Built_Files / ObjRepos / rdmobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-01  |  5.5 KB  |  168 lines

  1. [!outputon] // $Revision:   1.6.1.9  $
  2. // [!HeaderName] : Declaration of the [!CoClassName]
  3.  
  4. #ifndef [!IDEHeaderName]
  5. #define [!IDEHeaderName]
  6.  
  7. #include <Classes.hpp>
  8. #include <Controls.hpp>
  9. #include <StdCtrls.hpp>
  10. #include <Forms.hpp>
  11.  
  12. #include "[!TypeLibModuleName].H"
  13. #include <atl/atlvcl.h>
  14.  
  15.  
  16. [!if=(MTSObject, "TRUE")]
  17. #define _MTX_NOFORCE_LIBS
  18. #include <mtx.h>
  19. #include <vcl\mtshlpr.h>
  20. [!endif]
  21.  
  22. [!if=(ObjectControl, "TRUE")]
  23. // Forward ref. of IAppServer/IObjectControl implementor
  24. [!else]
  25. // Forward ref. of IAppServer implementor
  26. [!endif]
  27.  
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. /////////////////////////////////////////////////////////////////////////////
  31. class T[!CoClassName] : public TCRemoteDataModule
  32. {
  33. __published:  // IDE-managed Components
  34. private:      // User declarations
  35. public:       // User declarations
  36.   __fastcall T[!CoClassName](TComponent* Owner);
  37.  
  38. [!if=(ObjectControl, "TRUE")]
  39.   Classes::TNotifyEvent FOnActivate;        // Expose IObjectControl.Activate as VCL event
  40.   Classes::TNotifyEvent FOnDeactivate;      // Expose IObjectControl.Deactivate as VCL event
  41. [!endif]
  42. __published:
  43. [!if=(ObjectControl, "TRUE")]
  44.   __property Classes::TNotifyEvent OnActivate   = {read=FOnActivate,   write=FOnActivate};
  45.   __property Classes::TNotifyEvent OnDeactivate = {read=FOnDeactivate, write=FOnDeactivate};
  46. [!endif]
  47. };
  48.  
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. /////////////////////////////////////////////////////////////////////////////
  52. extern PACKAGE T[!CoClassName] *[!CoClassName];
  53.  
  54.  
  55. /////////////////////////////////////////////////////////////////////////////
  56. // [!ClassName]     Implements [!InterfaceName], default interface of [!CoClassName]
  57. [!if=(ConnectionPointsEnabled, "TRUE")]
  58. //                  and [!InterfaceName]Events, the default source interface
  59. [!endif]
  60. // ThreadingModel : [!ThreadingModel]
  61. // Dual Interface : [!Dual]
  62. // Event Support  : [!ConnectionPointsEnabled]
  63. // Default ProgID : [!ProgID]
  64. // Description    : [!Description]
  65. /////////////////////////////////////////////////////////////////////////////
  66. [!if=(ObjectControl, "TRUE")]
  67. class ATL_NO_VTABLE [!ClassName]: REMOTEDATAMODULE_IMPL([!ClassName], [!CoClassName], T[!CoClassName], [!InterfaceName]),
  68.                                   public IObjectControl
  69. [!if=(ConnectionPointsEnabled, "TRUE")]
  70.                                  ,public IConnectionPointContainerImpl<[!ClassName]>,
  71.                                   public TEvents_[!CoClassName]<[!ClassName]>
  72. [!endif]
  73. [!else]
  74. class ATL_NO_VTABLE [!ClassName]: REMOTEDATAMODULE_IMPL([!ClassName], [!CoClassName], T[!CoClassName], [!InterfaceName])
  75. [!if=(ConnectionPointsEnabled, "TRUE")]
  76.                                  ,public IConnectionPointContainerImpl<[!ClassName]>,
  77.                                   public TEvents_[!CoClassName]<[!ClassName]>
  78. [!endif]
  79. [!endif]
  80. {
  81. public:
  82.  
  83. BEGIN_COM_MAP([!ClassName])
  84. [!if=(ObjectControl, "TRUE")]
  85.   COM_INTERFACE_ENTRY(IObjectControl)
  86. [!endif]
  87.   RDMOBJECT_COM_INTERFACE_ENTRIES([!InterfaceName])
  88. [!if=(ConnectionPointsEnabled, "TRUE")]
  89.   COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  90. [!endif]
  91. END_COM_MAP()
  92.  
  93. [!if=(ConnectionPointsEnabled, "TRUE")]
  94. BEGIN_CONNECTION_POINT_MAP([!ClassName])
  95.   CONNECTION_POINT_ENTRY(DIID_I[!CoClassName]Events)
  96. END_CONNECTION_POINT_MAP()
  97.  
  98. [!endif]
  99.   // Data used when registering Object 
  100.   //
  101. [!if=(ThreadingModel, "Single")]
  102.   DECLARE_THREADING_MODEL(otSingle);
  103. [!endif]
  104. [!if=(ThreadingModel, "Apartment")]
  105.   DECLARE_THREADING_MODEL(otApartment);
  106. [!endif]
  107. [!if=(ThreadingModel, "Free")]
  108.   DECLARE_THREADING_MODEL(otFree);
  109. [!endif]
  110. [!if=(ThreadingModel, "Both")]
  111.   DECLARE_THREADING_MODEL(otBoth);
  112. [!endif]
  113.   DECLARE_PROGID("");
  114.   DECLARE_DESCRIPTION("[!Description]");
  115.  
  116.   // Function invoked to (un)register object
  117.   //
  118.   static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
  119.   {
  120.     TRemoteDataModuleRegistrar regObj(GetObjectCLSID(), GetProgID(), GetDescription());
  121.     // Disable these flags in order to disable use by socket or web connections.
  122.     // Also set other flags to configure the behavior of your application server.
  123.     // For more information, see atlmod.h and atlvcl.cpp.
  124.     regObj.Singleton = false;
  125.     regObj.EnableWeb = true;
  126.     regObj.EnableSocket = true;
  127.     return regObj.UpdateRegistry(bRegister);
  128.   }
  129.  
  130. [!if=(ObjectControl, "TRUE")]
  131.   // Inline methods to facilitate access to IObjectContext interface
  132.   //
  133.   void    SetComplete()       { m_spObjectContext->SetComplete();   } 
  134.   void    SetAbort()          { m_spObjectContext->SetAbort();      }
  135.   void    EnableCommit()      { m_spObjectContext->EnableCommit();  }
  136.   void    DisableCommit()     { m_spObjectContext->DisableCommit(); }
  137.   bool    IsInTransaction()   { return m_spObjectContext->IsInTransaction() != 0;  }
  138.   bool    IsSecurityEnabled() { return m_spObjectContext->IsSecurityEnabled() != 0;}
  139.   HRESULT IsCallerInRole(BSTR str, BOOL* bVal)    
  140.   { 
  141.     return m_spObjectContext->IsCallerInRole(str, bVal);   
  142.   }
  143.   bool    IsCallerInRole(BSTR str)
  144.   {
  145.     BOOL bVal;
  146.     OLECHECK(IsCallerInRole(str, &bVal));
  147.     return bVal != VARIANT_FALSE;
  148.   }
  149.  
  150. // IObjectControl
  151. public:
  152.   STDMETHOD(Activate)();
  153.   STDMETHOD_(BOOL, CanBePooled)();
  154.   STDMETHOD_(void, Deactivate)();
  155.  
  156.  
  157.   // Data member hold IObjectContext interface
  158.   //
  159.   CComPtr<IObjectContext> m_spObjectContext;
  160. [!endif]
  161.  
  162. // [!InterfaceName]
  163. protected:
  164. };
  165.  
  166. #endif  // [!IDEHeaderName]
  167.  
  168.