home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / interfac / iconnpt.cpp < prev    next >
C/C++ Source or Header  |  1995-05-03  |  4KB  |  185 lines

  1. /*
  2.  * ICONNPT.CPP
  3.  *
  4.  * Template implemenation of a connection point object.  Usually
  5.  * these objects will be stand-alone objects contained within
  6.  * a connection point container.
  7.  *
  8.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Microsoft
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #include "iconnpt.h"
  17.  
  18.  
  19. /*
  20.  * CConnectionPoint::CConnectionPoint
  21.  * CConnectionPoint::~CConnectionPoint
  22.  *
  23.  * Parameters (Constructor):
  24.  *  pObj            LPVOID of the object we're in.
  25.  */
  26.  
  27. CConnectionPoint::CConnectionPoint(LPVOID pObj)
  28.     {
  29.     m_cRef=0;
  30.     m_pObj=pObj;
  31.     return;
  32.     }
  33.  
  34. CConnectionPoint::~CConnectionPoint(void)
  35.     {
  36.     return;
  37.     }
  38.  
  39.  
  40.  
  41. /*
  42.  * CConnectionPoint::QueryInterface
  43.  * CConnectionPoint::AddRef
  44.  * CConnectionPoint::Release
  45.  *
  46.  * Purpose:
  47.  *  Non-delegating IUnknown members for CConnectionPoint.
  48.  */
  49.  
  50. STDMETHODIMP CConnectionPoint::QueryInterface(REFIID riid
  51.     , LPVOID *ppv)
  52.     {
  53.     *ppv=NULL;
  54.  
  55.     if (IID_IUnknown==riid || IID_IConnectionPoint==riid)
  56.         *ppv=(LPVOID)this;
  57.  
  58.     if (NULL!=*ppv)
  59.         {
  60.         ((LPUNKNOWN)*ppv)->AddRef();
  61.         return NOERROR;
  62.         }
  63.  
  64.     return ResultFromScode(E_NOINTERFACE);
  65.     }
  66.  
  67. STDMETHODIMP_(ULONG) CConnectionPoint::AddRef(void)
  68.     {
  69.     return ++m_cRef;
  70.     }
  71.  
  72. STDMETHODIMP_(ULONG) CConnectionPoint::Release(void)
  73.     {
  74.     if (0!=--m_cRef)
  75.         return m_cRef;
  76.  
  77.     delete this;
  78.     return 0;
  79.     }
  80.  
  81.  
  82.  
  83. /*
  84.  * CConnectionPoint::GetConnectionInterface
  85.  *
  86.  * Purpose:
  87.  *  Returns the IID of the outgoing interface supported through
  88.  *  this connection point.
  89.  *
  90.  * Parameters:
  91.  *  pIID            IID * in which to store the IID.
  92.  */
  93.  
  94. STDMETHODIMP CConnectionPoint::GetConnectionInterface(IID *pIID)
  95.     {
  96.     return ResultFromScode(E_NOTIMPL);
  97.     }
  98.  
  99.  
  100.  
  101. /*
  102.  * CConnectionPoint::GetConnectionPointContainer
  103.  *
  104.  * Purpose:
  105.  *  Returns a pointer to the IConnectionPointContainer that
  106.  *  is manageing this connection point.
  107.  *
  108.  * Parameters:
  109.  *  ppCPC           IConnectionPointContainer ** in which to return
  110.  *                  the pointer after calling AddRef.
  111.  */
  112.  
  113. STDMETHODIMP CConnectionPoint::GetConnectionPointContainer
  114.     (IConnectionPointContainer **ppCPC)
  115.     {
  116.     *ppCPC=NULL;
  117.     return ResultFromScode(E_NOTIMPL);
  118.     }
  119.  
  120.  
  121.  
  122. /*
  123.  * CConnectionPoint::Advise
  124.  *
  125.  * Purpose:
  126.  *  Provides this connection point with a notification sink to
  127.  *  call whenever the appropriate outgoing function/event occurs.
  128.  *
  129.  * Parameters:
  130.  *  pUnkSink        LPUNKNOWN to the sink to notify.  The connection
  131.  *                  point must QueryInterface on this pointer to obtain
  132.  *                  the proper interface to call.  The connection
  133.  *                  point must also insure that any pointer held has
  134.  *                  a reference count (QueryInterface will do it).
  135.  *  pdwCookie       DWORD * in which to store the connection key for
  136.  *                  later calls to Unadvise.
  137.  */
  138.  
  139. STDMETHODIMP CConnectionPoint::Advise(LPUNKNOWN pUnkSink
  140.     , DWORD *pdwCookie)
  141.     {
  142.     *pdwCookie=0;
  143.     return ResultFromScode(E_NOTIMPL);
  144.     }
  145.  
  146.  
  147.  
  148. /*
  149.  * CConnectionPoint::Unadvise
  150.  *
  151.  * Purpose:
  152.  *  Terminates the connection to the notification sink identified
  153.  *  with dwCookie (that was returned from Advise).  The connection
  154.  *  point has to Release any held pointers for that sink.
  155.  *
  156.  * Parameters:
  157.  *  dwCookie        DWORD connection key from Advise.
  158.  */
  159.  
  160. STDMETHODIMP CConnectionPoint::Unadvise(DWORD dwCookie)
  161.     {
  162.     return ResultFromScode(E_NOTIMPL);
  163.     }
  164.  
  165.  
  166. /*
  167.  * CConnectionPoint::EnumConnections
  168.  *
  169.  * Purpose:
  170.  *  Creates and returns an enumerator object with the
  171.  *  IEnumConnections interface that will enumerate the IUnknown
  172.  *  pointers of each connected sink.
  173.  *
  174.  * Parameters:
  175.  *  ppEnum          LPENUMCONNECTIONS in which to store the
  176.  *                  IEnumConnections pointer.
  177.  */
  178.  
  179. STDMETHODIMP CConnectionPoint::EnumConnections
  180.     (LPENUMCONNECTIONS *ppEnum)
  181.     {
  182.     *ppEnum=NULL;
  183.     return ResultFromScode(E_NOTIMPL);
  184.     }
  185.