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 / chap06 / ekoala3 / koala.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.1 KB  |  85 lines

  1. /*
  2.  * KOALA.H
  3.  * Koala Object for EXE Servers, Chapter 6
  4.  *
  5.  * Classes that implement an object with IExternalConnection.
  6.  *
  7.  * Copyright (c)1993-1995 Microsoft Corporation, All Right Reserved
  8.  *
  9.  * Kraig Brockschmidt, Microsoft
  10.  * Internet  :  kraigb@microsoft.com
  11.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  12.  */
  13.  
  14.  
  15. #ifndef _KOALA_H_
  16. #define _KOALA_H_
  17.  
  18. #define CHAPTER6
  19. #include <inole.h>
  20.  
  21. //KOALA.CPP
  22.  
  23. //CHAPTER6MOD
  24. class CImpIPersist;
  25. typedef CImpIPersist *PCImpIPersist;
  26.  
  27. class CKoala : public IExternalConnection
  28. //End CHAPTER6MOD
  29.     {
  30.     protected:
  31.         ULONG           m_cRef;         //Object reference count
  32.         LPUNKNOWN       m_pUnkOuter;    //Controlling unknown
  33.         PFNDESTROYED    m_pfnDestroy;   //To call on closure
  34.  
  35.         //CHAPTER6MOD
  36.         DWORD           m_cStrong;      //Strong lock count
  37.         DWORD           m_cWeak;        //Weak lock count
  38.  
  39.         PCImpIPersist   m_pImpIPersist; //Another interface
  40.         //End CHAPTER6MOD
  41.  
  42.     public:
  43.         CKoala(LPUNKNOWN, PFNDESTROYED);
  44.         ~CKoala(void);
  45.  
  46.         BOOL Init(void);
  47.  
  48.         //Non-delegating object IUnknown
  49.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  50.         STDMETHODIMP_(ULONG) AddRef(void);
  51.         STDMETHODIMP_(ULONG) Release(void);
  52.  
  53.         //CHAPTER6MOD
  54.         STDMETHODIMP_(DWORD) AddConnection(DWORD, DWORD);
  55.         STDMETHODIMP_(DWORD) ReleaseConnection(DWORD, DWORD, BOOL);
  56.         //End CHAPTER6MOD
  57.     };
  58.  
  59. typedef CKoala *PCKoala;
  60.  
  61.  
  62. //CHAPTER6MOD
  63.  
  64. class CImpIPersist : public IPersist
  65.     {
  66.     protected:
  67.         ULONG           m_cRef;      //Interface reference count
  68.         PCKoala         m_pObj;      //Back pointer to the object
  69.         LPUNKNOWN       m_pUnkOuter; //For delegation
  70.  
  71.     public:
  72.         CImpIPersist(PCKoala, LPUNKNOWN);
  73.         ~CImpIPersist(void);
  74.  
  75.         STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  76.         STDMETHODIMP_(ULONG) AddRef(void);
  77.         STDMETHODIMP_(ULONG) Release(void);
  78.  
  79.         STDMETHODIMP GetClassID(LPCLSID);
  80.     };
  81.  
  82. //End CHAPTER6MOD
  83.  
  84. #endif //_KOALA_H_
  85.