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 / dllserve / sample.h < prev    next >
C/C++ Source or Header  |  1997-08-05  |  5KB  |  128 lines

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