home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / wincom / dllcom / public / dllobj.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.1 KB  |  59 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef __DllComClassObject_H
  20. #define __DllComClassObject_H
  21.  
  22. //  ALL COM IMPLEMENTED OBJECTS MUST DERIVE FROM THIS
  23. //      CLASS (or do what it does).
  24.  
  25. //  All your COM interface exposing classes which you implement
  26. //      in your consumer DLL must derive from this class
  27. //      such that it can perform some minimal DLL maintenence
  28. //      and ensure that you do not forget to do so.
  29. class CComClass {
  30. private:
  31.     CRefDll m_Ref;  //  Ref count dll instance.
  32. public:
  33.     CComClass(IUnknown *pAggregate = NULL);
  34.     virtual ~CComClass();
  35.  
  36.     //  external IUnknown implementation inside of the class.
  37. private:
  38.     DWORD m_ulCount;
  39.     IUnknown *m_pAggregate;
  40. public:
  41.     HRESULT ObjectQueryInterface(REFIID iid, void **ppObj, BOOL bIUnknown = FALSE);
  42.     virtual HRESULT CustomQueryInterface(REFIID iid, void **ppObj);
  43.     DWORD ObjectAddRef(BOOL bIUnknown = FALSE);
  44.     virtual DWORD CustomAddRef();
  45.     DWORD ObjectRelease(BOOL bIUnknown = FALSE);
  46.     virtual DWORD CustomRelease();
  47.  
  48.     //  Nested class interface implementation.
  49. private:
  50.     class CImplUnknown : public IUnknown    {
  51.     public:
  52.         CComClass *m_pObject;
  53.         STDMETHODIMP QueryInterface(REFIID iid, void **ppObj);
  54.         STDMETHODIMP_(DWORD) AddRef();
  55.         STDMETHODIMP_(DWORD) Release();
  56.     } m_IUnknown;
  57. };
  58.  
  59. #endif // __DllComClassObject_H