WvStreams
|
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 * 00003 * XPLC - Cross-Platform Lightweight Components 00004 * Copyright (C) 2002-2003, Pierre Phaneuf 00005 * Copyright (C) 2002, Net Integration Technologies, Inc. 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 */ 00022 00023 #include <xplc/IFactory.h> 00024 #include <xplc/core.h> 00025 #include <xplc/utils.h> 00026 #include "new.h" 00027 00028 UUID_MAP_BEGIN(NewMoniker) 00029 UUID_MAP_ENTRY(IObject) 00030 UUID_MAP_ENTRY(IMoniker) 00031 UUID_MAP_END 00032 00033 NewMoniker::~NewMoniker() { 00034 } 00035 00036 IObject* NewMoniker::resolve(const char* aName) { 00037 IServiceManager* servmgr; 00038 IMoniker* monikers; 00039 IFactory* factory; 00040 IObject* obj = 0; 00041 00042 servmgr = XPLC_getServiceManager(); 00043 if(servmgr) { 00044 monikers = mutate<IMoniker>(servmgr->getObject(XPLC_monikers)); 00045 00046 if(monikers) { 00047 factory = mutate<IFactory>(monikers->resolve(aName)); 00048 00049 if(factory) { 00050 obj = factory->createObject(); 00051 factory->release(); 00052 } 00053 00054 monikers->release(); 00055 } 00056 00057 servmgr->release(); 00058 } 00059 00060 return obj; 00061 } 00062