1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3
* The contents of this file are subject to the Netscape Public License
4
* Version 1.1 (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/
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
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
19
#ifndef nsComponentManagerUtils_h__
20
#define nsComponentManagerUtils_h__
23
* Do not include this file directly. Instead,
24
* |#include "nsIComponentManager.h"|.
31
#ifndef nsComponentManagerObsolete_h___
32
#include "nsComponentManagerObsolete.h"
35
#define NS_COMPONENTMANAGER_CID \
36
{ /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \
40
{0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
43
class NS_COM nsCreateInstanceByCID : public nsCOMPtr_helper
46
nsCreateInstanceByCID( const nsCID& aCID, nsISupports* aOuter, nsresult* aErrorPtr )
51
// nothing else to do here
54
virtual nsresult operator()( const nsIID&, void** ) const;
62
class NS_COM nsCreateInstanceByContractID : public nsCOMPtr_helper
65
nsCreateInstanceByContractID( const char* aContractID, nsISupports* aOuter, nsresult* aErrorPtr )
66
: mContractID(aContractID),
70
// nothing else to do here
73
virtual nsresult operator()( const nsIID&, void** ) const;
76
const char* mContractID;
82
const nsCreateInstanceByCID
83
do_CreateInstance( const nsCID& aCID, nsresult* error = 0 )
85
return nsCreateInstanceByCID(aCID, 0, error);
89
const nsCreateInstanceByCID
90
do_CreateInstance( const nsCID& aCID, nsISupports* aOuter, nsresult* error = 0 )
92
return nsCreateInstanceByCID(aCID, aOuter, error);
96
const nsCreateInstanceByContractID
97
do_CreateInstance( const char* aContractID, nsresult* error = 0 )
99
return nsCreateInstanceByContractID(aContractID, 0, error);
103
const nsCreateInstanceByContractID
104
do_CreateInstance( const char* aContractID, nsISupports* aOuter, nsresult* error = 0 )
106
return nsCreateInstanceByContractID(aContractID, aOuter, error);
109
// type-safe shortcuts for calling |CreateInstance|
110
template <class DestinationType>
113
CallCreateInstance( const nsCID &aClass,
114
nsISupports *aDelegate,
115
DestinationType** aDestination )
117
NS_PRECONDITION(aDestination, "null parameter");
119
return nsComponentManager::CreateInstance(aClass, aDelegate,
120
NS_GET_IID(DestinationType),
121
NS_REINTERPRET_CAST(void**, aDestination));
124
template <class DestinationType>
127
CallCreateInstance( const nsCID &aClass,
128
DestinationType** aDestination )
130
NS_PRECONDITION(aDestination, "null parameter");
132
return nsComponentManager::CreateInstance(aClass, nsnull,
133
NS_GET_IID(DestinationType),
134
NS_REINTERPRET_CAST(void**, aDestination));
137
template <class DestinationType>
140
CallCreateInstance( const char *aContractID,
141
nsISupports *aDelegate,
142
DestinationType** aDestination )
144
NS_PRECONDITION(aContractID, "null parameter");
145
NS_PRECONDITION(aDestination, "null parameter");
147
return nsComponentManager::CreateInstance(aContractID,
149
NS_GET_IID(DestinationType),
150
NS_REINTERPRET_CAST(void**, aDestination));
153
template <class DestinationType>
156
CallCreateInstance( const char *aContractID,
157
DestinationType** aDestination )
159
NS_PRECONDITION(aContractID, "null parameter");
160
NS_PRECONDITION(aDestination, "null parameter");
162
return nsComponentManager::CreateInstance(aContractID, nsnull,
163
NS_GET_IID(DestinationType),
164
NS_REINTERPRET_CAST(void**, aDestination));
167
/* keys for registry use */
168
extern const char xpcomKeyName[];
169
extern const char xpcomComponentsKeyName[];
170
extern const char lastModValueName[];
171
extern const char fileSizeValueName[];
172
extern const char nativeComponentType[];
173
extern const char staticComponentType[];
175
#endif /* nsComponentManagerUtils_h__ */