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 / perclien / textsink.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-05  |  4.9 KB  |  130 lines

  1. /*+==========================================================================
  2.   File:      TEXTSINK.H
  3.  
  4.   Summary:   Include file for the COTextPageSink COM object class.
  5.  
  6.              COTextPageSink offers a main IUnknown standard interface and
  7.              the custom ITextPageSink interface (outgoing connection
  8.              events from COTextPage objects). This multiple interface COM
  9.              Object Class is achieved via the technique of nested classes.
  10.              The implementation of the ITextPageSink interface is nested
  11.              inside of the COTextPageSink Class.
  12.  
  13.              For a comprehensive tutorial code tour of this module's
  14.              contents and offerings see the tutorial PERCLIEN.HTM
  15.              file. For more specific technical details on the internal
  16.              workings see the comments dispersed throughout the module's
  17.              source code.
  18.  
  19.   Functions: .
  20.  
  21.   Classes:   COTextPageSink.
  22.  
  23.   Origin:    5-25-96: atrent - Editor-inheritance from SINK.H in the
  24.              STOCLIEN Tutorial Code Sample.
  25.  
  26. ----------------------------------------------------------------------------
  27.   This file is part of the Microsoft COM Tutorial Code Samples.
  28.  
  29.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  30.  
  31.   This source code is intended only as a supplement to Microsoft
  32.   Development Tools and/or on-line documentation.  See these other
  33.   materials for detailed information regarding Microsoft code samples.
  34.  
  35.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  36.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  37.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  38.   PARTICULAR PURPOSE.
  39. ==========================================================================+*/
  40.  
  41. #if !defined(TEXTSINK_H)
  42. #define TEXTSINK_H
  43.  
  44. #ifdef __cplusplus
  45.  
  46.  
  47. /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
  48.   ObjectClass: COTextPageSink
  49.  
  50.   Summary:     The main Sink COM object class for COTextPageSink COM
  51.                objects. COM objects of this class offer the ITextPageSink
  52.                sink interface supporting various TextPage events. The
  53.                mulitple interfaces on this COM object are constructed via
  54.                the nested interface classes technique.
  55.  
  56.   Interfaces:  IUnknown
  57.                  Standard interface providing COM object features.
  58.                ITextPageSink
  59.                  Sink interface for TextPage events.
  60.  
  61.   Aggregation: Yes, COTextPageSink COM Objects are aggregatable by passing
  62.                a non-NULL pUnkOuter IUnknown pointer into the constructor.
  63. O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
  64. class COTextPageSink : public IUnknown
  65. {
  66.   public:
  67.     // Main Object Constructor & Destructor.
  68.     COTextPageSink(IUnknown* pUnkOuter, CGuiText* pGuiText);
  69.     ~COTextPageSink(void);
  70.  
  71.     // IUnknown methods. Main object, non-delegating.
  72.     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  73.     STDMETHODIMP_(ULONG) AddRef(void);
  74.     STDMETHODIMP_(ULONG) Release(void);
  75.  
  76.   private:
  77.     // We declare nested class interface implementations here.
  78.  
  79.     class CImpITextPageSink : public ITextPageSink
  80.     {
  81.       public:
  82.         // Interface Implementation Constructor & Destructor.
  83.         CImpITextPageSink(COTextPageSink* pCO, IUnknown* pUnkOuter);
  84.         ~CImpITextPageSink(void);
  85.  
  86.         // IUnknown methods.
  87.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  88.         STDMETHODIMP_(ULONG) AddRef(void);
  89.         STDMETHODIMP_(ULONG) Release(void);
  90.  
  91.         // ITextPageSink methods.
  92.         STDMETHODIMP         Loaded(void);
  93.         STDMETHODIMP         Saved(void);
  94.         STDMETHODIMP         Put(void);
  95.         STDMETHODIMP         Cleared(void);
  96.  
  97.       private:
  98.         // Data private to this interface implementation of ITextPage.
  99.         COTextPageSink*  m_pCO;          // Parent Object back pointer.
  100.         IUnknown*        m_pUnkOuter;    // Outer unknown for Delegation.
  101.     };
  102.  
  103.     // Make the otherwise private and nested ITextPageSink interface
  104.     // implementation a friend to COM object instantiations of this
  105.     // COTextPageSink COM object class.
  106.     friend CImpITextPageSink;
  107.  
  108.     // Private data of COTextPageSink COM objects.
  109.  
  110.     // Nested ITextPageSink implementation instantiation.  This
  111.     // ITextPageSink interface is instantiated inside this COTextPageSink
  112.     // object as a native interface.
  113.     CImpITextPageSink    m_ImpITextPageSink;
  114.  
  115.     // Main Object reference count.
  116.     ULONG                m_cRefs;
  117.  
  118.     // Outer unknown (aggregation delegation). Used when this COM object
  119.     // is being aggregated.
  120.     IUnknown*            m_pUnkOuter;
  121.  
  122.     // Pointer to the main object that can service the Sink events.
  123.     CGuiText*            m_pGuiText;
  124. };
  125.  
  126. #endif // __cplusplus
  127.  
  128.  
  129. #endif // TEXTSINK_H
  130.