2014-06-30 19:39:45 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-10-16 07:35:52 +04:00
|
|
|
|
2004-11-25 01:48:45 +03:00
|
|
|
#ifndef nsServiceManagerUtils_h__
|
|
|
|
#define nsServiceManagerUtils_h__
|
2001-10-16 07:35:52 +04:00
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceByCID
|
2004-11-25 01:48:45 +03:00
|
|
|
do_GetService(const nsCID& aCID)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceByCID(aCID);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceByCIDWithError
|
|
|
|
do_GetService(const nsCID& aCID, nsresult* aError)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceByCIDWithError(aCID, aError);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceByContractID
|
2004-11-25 01:48:45 +03:00
|
|
|
do_GetService(const char* aContractID)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceByContractID(aContractID);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceByContractIDWithError
|
|
|
|
do_GetService(const char* aContractID, nsresult* aError)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceByContractIDWithError(aContractID, aError);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2002-02-19 01:57:47 +03:00
|
|
|
class nsGetServiceFromCategory : public nsCOMPtr_helper
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
public:
|
|
|
|
nsGetServiceFromCategory(const char* aCategory, const char* aEntry,
|
|
|
|
nsresult* aErrorPtr)
|
|
|
|
: mCategory(aCategory)
|
|
|
|
, mEntry(aEntry)
|
|
|
|
, mErrorPtr(aErrorPtr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const;
|
|
|
|
protected:
|
|
|
|
const char* mCategory;
|
|
|
|
const char* mEntry;
|
|
|
|
nsresult* mErrorPtr;
|
2001-10-16 07:35:52 +04:00
|
|
|
};
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceFromCategory
|
|
|
|
do_GetServiceFromCategory(const char* aCategory, const char* aEntry,
|
|
|
|
nsresult* aError = 0)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceFromCategory(aCategory, aEntry, aError);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
NS_COM_GLUE nsresult CallGetService(const nsCID& aClass, const nsIID& aIID,
|
|
|
|
void** aResult);
|
2004-11-25 01:48:45 +03:00
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
NS_COM_GLUE nsresult CallGetService(const char* aContractID, const nsIID& aIID,
|
|
|
|
void** aResult);
|
2004-11-25 01:48:45 +03:00
|
|
|
|
2001-10-16 07:35:52 +04:00
|
|
|
// type-safe shortcuts for calling |GetService|
|
2014-06-27 05:35:39 +04:00
|
|
|
template<class DestinationType>
|
|
|
|
inline nsresult
|
|
|
|
CallGetService(const nsCID& aClass,
|
|
|
|
DestinationType** aDestination)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
NS_PRECONDITION(aDestination, "null parameter");
|
|
|
|
|
|
|
|
return CallGetService(aClass,
|
|
|
|
NS_GET_TEMPLATE_IID(DestinationType),
|
|
|
|
reinterpret_cast<void**>(aDestination));
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
template<class DestinationType>
|
|
|
|
inline nsresult
|
|
|
|
CallGetService(const char* aContractID,
|
|
|
|
DestinationType** aDestination)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
NS_PRECONDITION(aContractID, "null parameter");
|
|
|
|
NS_PRECONDITION(aDestination, "null parameter");
|
|
|
|
|
|
|
|
return CallGetService(aContractID,
|
|
|
|
NS_GET_TEMPLATE_IID(DestinationType),
|
|
|
|
reinterpret_cast<void**>(aDestination));
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|