WvStreams
xplc-cxx
xplc.cc
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
*
3
* XPLC - Cross-Platform Lightweight Components
4
* Copyright (C) 2002-2004, Net Integration Technologies, Inc.
5
* Copyright (C) 2003-2004, Pierre Phaneuf
6
*
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.
11
*
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.
16
*
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
21
*
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.
31
*/
32
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
>
38
39
void
XPLC::addModuleDirectory
(
const
char
* directory) {
40
xplc_ptr<IModuleManagerFactory>
factory(get<IModuleManagerFactory>(XPLC_moduleManagerFactory));
41
42
if
(!factory)
43
return
;
44
45
xplc_ptr<IServiceHandler>
modulemgr(factory->createModuleManager(directory));
46
47
if
(!modulemgr)
48
return
;
49
50
servmgr->addHandler(modulemgr);
51
}
52
53
IObject
*
XPLC::create
(
const
UUID
& cid) {
54
if
(!servmgr)
55
return
0;
56
57
xplc_ptr<IFactory>
factory(mutate<IFactory>(servmgr->getObject(cid)));
58
59
if
(!factory)
60
return
0;
61
62
return
factory->createObject();
63
}
64
65
IObject
*
XPLC::create
(
const
char
* aMoniker) {
66
if
(!servmgr)
67
return
0;
68
69
xplc_ptr<IMoniker>
moniker(mutate<IMoniker>(servmgr->getObject(XPLC_monikers)));
70
if
(!moniker)
71
return
0;
72
73
xplc_ptr<IFactory>
factory(mutate<IFactory>(moniker->resolve(aMoniker)));
74
if
(!factory)
75
return
0;
76
77
return
factory->createObject();
78
}
79
80
xplc.h
XPLC::create
IObject * create(const UUID &cid)
Object creation helper.
Definition:
xplc.cc:53
IObject
Definition:
IObject.h:65
XPLC::addModuleDirectory
void addModuleDirectory(const char *directory)
Adds a directory to the module loader path.
Definition:
xplc.cc:39
_GUID
The structure underlying UUIDs.
Definition:
uuid.h:94
xplc_ptr
Smart pointer class for XPLC interfaces.
Definition:
ptr.h:56
ptr.h
Generated by
1.8.17