1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // IWYU pragma: private, include "nsISupports.h"
7 
8 #ifndef nsISupportsBase_h__
9 #define nsISupportsBase_h__
10 
11 #ifndef nscore_h___
12 #  include "nscore.h"
13 #endif
14 
15 #ifndef nsID_h__
16 #  include "nsID.h"
17 #endif
18 
19 /*@{*/
20 /**
21  * IID for the nsISupports interface
22  * {00000000-0000-0000-c000-000000000046}
23  *
24  * To maintain binary compatibility with COM's IUnknown, we define the IID
25  * of nsISupports to be the same as that of COM's IUnknown.
26  */
27 #define NS_ISUPPORTS_IID                             \
28   {                                                  \
29     0x00000000, 0x0000, 0x0000, {                    \
30       0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 \
31     }                                                \
32   }
33 
34 /**
35  * Basic component object model interface. Objects which implement
36  * this interface support runtime interface discovery (QueryInterface)
37  * and a reference counted memory model (AddRef/Release). This is
38  * modelled after the win32 IUnknown API.
39  */
40 class NS_NO_VTABLE nsISupports {
41  public:
42   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISUPPORTS_IID)
43 
44   /**
45    * @name Methods
46    */
47 
48   //@{
49   /**
50    * A run time mechanism for interface discovery.
51    * @param aIID [in] A requested interface IID
52    * @param aInstancePtr [out] A pointer to an interface pointer to
53    * receive the result.
54    * @return <b>NS_OK</b> if the interface is supported by the associated
55    * instance, <b>NS_NOINTERFACE</b> if it is not.
56    *
57    * aInstancePtr must not be null.
58    */
59   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) = 0;
60   /**
61    * Increases the reference count for this interface.
62    * The associated instance will not be deleted unless
63    * the reference count is returned to zero.
64    *
65    * @return The resulting reference count.
66    */
67   NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
68 
69   /**
70    * Decreases the reference count for this interface.
71    * Generally, if the reference count returns to zero,
72    * the associated instance is deleted.
73    *
74    * @return The resulting reference count.
75    */
76   NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
77 
78   //@}
79 };
80 
81 NS_DEFINE_STATIC_IID_ACCESSOR(nsISupports, NS_ISUPPORTS_IID)
82 
83 /*@}*/
84 
85 #endif
86