home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / tutsamp / licserve / sample.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-05  |  4.6 KB  |  129 lines

  1. /*+==========================================================================
  2.   File:      SAMPLE.H
  3.  
  4.   Summary:   Declares a COLicCarSample utility COM object used to
  5.              implement the server as a code sample (mainly with an Init
  6.              method to enable setting up Trace logging of activity in the
  7.              server to the logging facility in the Client).
  8.  
  9.              For a comprehensive tutorial code tour of this module's
  10.              contents and offerings see the tutorial LICSERVE.HTM
  11.              file. For more specific technical details on the internal
  12.              workings see the comments dispersed throughout the module's
  13.              source code.
  14.  
  15.   Classes:   COLicCarSample.
  16.  
  17.   Functions: none
  18.  
  19.   Origin:    10-5-95: atrent - Editor-inheritance from SAMPLE.H in
  20.                the DLLSERVE Tutorial Code Sample.
  21.  
  22. ----------------------------------------------------------------------------
  23.   This file is part of the Microsoft COM Tutorial Code Samples.
  24.  
  25.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  26.  
  27.   This source code is intended only as a supplement to Microsoft
  28.   Development Tools and/or on-line documentation.  See these other
  29.   materials for detailed information regarding Microsoft code samples.
  30.  
  31.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  32.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  33.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  34.   PARTICULAR PURPOSE.
  35. ==========================================================================+*/
  36.  
  37. #if !defined(SAMPLE_H)
  38. #define SAMPLE_H
  39.  
  40. #ifdef __cplusplus
  41.  
  42. /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
  43.   ObjectClass: COLicCarSample
  44.  
  45.   Summary:     Utility LicCarSample COM Object Class for the LICSERVE
  46.                server as a code sample.
  47.  
  48.   Interfaces:  IUnknown
  49.                  Standard interface providing COM object features.
  50.                ISample
  51.                  Sample-specific Utility services for server as a whole.
  52.  
  53.   Aggregation: Yes, COLicCarSample COM objects are aggregatable by
  54.                passing a non-NULL pUnkOuter IUnknown pointer into the
  55.                constructor.
  56. O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
  57. class COLicCarSample : public IUnknown
  58. {
  59.   public:
  60.     // Main Object Constructor & Destructor.
  61.     COLicCarSample(IUnknown* pUnkOuter, CServer* pServer);
  62.     ~COLicCarSample(void);
  63.  
  64.     // IUnknown methods. Main object, non-delegating.
  65.     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  66.     STDMETHODIMP_(ULONG) AddRef(void);
  67.     STDMETHODIMP_(ULONG) Release(void);
  68.  
  69.   private:
  70.     // We declare nested class interface implementations here.
  71.  
  72.     // We implement the ISample interface in this COLicCarSample
  73.     // COM object class.
  74.     class CImpISample : public ISample
  75.     {
  76.       public:
  77.         // Interface Implementation Constructor & Destructor.
  78.         CImpISample(
  79.           COLicCarSample* pBackObj,
  80.           IUnknown* pUnkOuter,
  81.           CServer* pServer);
  82.         ~CImpISample(void);
  83.  
  84.         // IUnknown methods.
  85.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  86.         STDMETHODIMP_(ULONG) AddRef(void);
  87.         STDMETHODIMP_(ULONG) Release(void);
  88.  
  89.         // ISample methods.
  90.         STDMETHODIMP         Init(HWND, PVOID);
  91.         STDMETHODIMP         AboutBox(HWND);
  92.  
  93.       private:
  94.         // Data private to this interface implementation of ISample.
  95.         ULONG            m_cRefI;        // Interface Ref Count (debugging).
  96.         COLicCarSample*  m_pBackObj;     // Parent Object back pointer.
  97.         IUnknown*        m_pUnkOuter;    // Outer unknown for Delegation.
  98.         CServer*         m_pServer;      // Server Control object.
  99.     };
  100.  
  101.     // Make the otherwise private and nested ISample interface
  102.     // implementation a friend to COM object instantiations of this
  103.     // selfsame COLicCarSample COM object class.
  104.     friend CImpISample;
  105.  
  106.     // Private data of COLicCarSample COM objects.
  107.  
  108.     // Nested ISample implementation instantiation.
  109.     CImpISample      m_ImpISample;
  110.  
  111.     // Main Object reference count.
  112.     ULONG            m_cRefs;
  113.  
  114.     // Outer unknown (aggregation & delegation). Used when this
  115.     // COLicCarSample object is being aggregated.  Otherwise it is used
  116.     // for delegation if this object is reused via containment.
  117.     IUnknown*        m_pUnkOuter;
  118.  
  119.     // Pointer to this component server's control object.
  120.     CServer*         m_pServer;
  121. };
  122.  
  123. typedef COLicCarSample* PCOLicCarSample;
  124.  
  125. #endif // __cplusplus
  126.  
  127.  
  128. #endif // SAMPLE_H
  129.