Add nsService constructor that allows you to get a service by ProgID using the statically linked nsServiceManager API.

git-svn-id: svn://10.0.0.236/trunk@33969 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
waterson%netscape.com
1999-06-07 02:24:29 +00:00
parent 241cd05c79
commit 96e56379e8

View File

@@ -234,6 +234,17 @@ public:
// if (NS_FAILED(rv)) return rv;
// compMgr->RegisterComponent(...); // use the service
// }
//
// Note that both NS_WITH_SERVICE and NS_WITH_SERVICE1 can be used with a
// "progid" as well as a "clsid"; for example,
//
// nsresult rv;
// NS_WITH_SERVICE(nsIObserverService,
// observer,
// "component://netscape/observer-service", /* or NS_OBSERVERSERVICE_PROGID */
// &rv);
//
#define NS_WITH_SERVICE(T, var, cid, rvAddr) \
nsService _serv##var(cid, T::GetIID(), rvAddr); \
@@ -280,6 +291,16 @@ public:
(nsISupports**)&mService);
}
nsService(const char* aProgID, const nsIID& aIID, nsresult *rv)
: mService(0)
{
*rv = nsComponentManager::ProgIDToCLSID(aProgID, &mCID);
if (NS_FAILED(*rv)) return;
*rv = nsServiceManager::GetService(mCID, aIID,
(nsISupports**)&mService);
}
~nsService() {
if (mService) { // mService could be null if the constructor fails
nsresult rv = NS_OK;