Fix several warnings that appear in gcc 4.3.2.
[wvstreams.git] / xplc-cxx / xplc.cc
blob36c98e7803ee26d9a3f1fb5e8a1b0249d6c2bd3e
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * XPLC - Cross-Platform Lightweight Components
4 * Copyright (C) 2002-2004, Net Integration Technologies, Inc.
5 * Copyright (C) 2003-2004, Pierre Phaneuf
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
22 * As a special exception, you may use this file as part of a free
23 * software library without restriction. Specifically, if other files
24 * instantiate templates or use macros or inline functions from this
25 * file, or you compile this file and link it with other files to
26 * produce an executable, this file does not by itself cause the
27 * resulting executable to be covered by the GNU Lesser General Public
28 * License. This exception does not however invalidate any other
29 * reasons why the executable file might be covered by the GNU Lesser
30 * General Public License.
33 #include <xplc/IMoniker.h>
34 #include <xplc/IFactory.h>
35 #include <xplc/IModuleManagerFactory.h>
36 #include <xplc/xplc.h>
37 #include <xplc/ptr.h>
39 void XPLC::addModuleDirectory(const char* directory) {
40 xplc_ptr<IModuleManagerFactory> factory(get<IModuleManagerFactory>(XPLC_moduleManagerFactory));
42 if(!factory)
43 return;
45 xplc_ptr<IServiceHandler> modulemgr(factory->createModuleManager(directory));
47 if(!modulemgr)
48 return;
50 servmgr->addHandler(modulemgr);
53 IObject* XPLC::create(const UUID& cid) {
54 if(!servmgr)
55 return 0;
57 xplc_ptr<IFactory> factory(mutate<IFactory>(servmgr->getObject(cid)));
59 if(!factory)
60 return 0;
62 return factory->createObject();
65 IObject* XPLC::create(const char* aMoniker) {
66 if(!servmgr)
67 return 0;
69 xplc_ptr<IMoniker> moniker(mutate<IMoniker>(servmgr->getObject(XPLC_monikers)));
70 if(!moniker)
71 return 0;
73 xplc_ptr<IFactory> factory(mutate<IFactory>(moniker->resolve(aMoniker)));
74 if(!factory)
75 return 0;
77 return factory->createObject();