WvStreams
new.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-2003, Pierre Phaneuf
5 * Copyright (C) 2002, Net Integration Technologies, Inc.
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
23#include <xplc/IFactory.h>
24#include <xplc/core.h>
25#include <xplc/utils.h>
26#include "new.h"
27
32
33NewMoniker::~NewMoniker() {
34}
35
36IObject* NewMoniker::resolve(const char* aName) {
37 IServiceManager* servmgr;
38 IMoniker* monikers;
39 IFactory* factory;
40 IObject* obj = 0;
41
42 servmgr = XPLC_getServiceManager();
43 if(servmgr) {
44 monikers = mutate<IMoniker>(servmgr->getObject(XPLC_monikers));
45
46 if(monikers) {
47 factory = mutate<IFactory>(monikers->resolve(aName));
48
49 if(factory) {
50 obj = factory->createObject();
51 factory->release();
52 }
53
54 monikers->release();
55 }
56
57 servmgr->release();
58 }
59
60 return obj;
61}
62
Common object creation interface.
Definition: IFactory.h:37
virtual IObject * createObject()=0
Creates an object.
An interface for obtaining an IObject given a moniker string.
Definition: IMoniker.h:50
virtual IObject * resolve(const char *moniker)=0
Given a moniker string, return the IObject it refers to, or NULL if no objects match.
The basic interface which is included by all other XPLC interfaces and objects.
Definition: IObject.h:65
virtual unsigned int release()=0
Indicate that you are finished using this object.
virtual IObject * getObject(const UUID &)=0
Get the object corresponding to the given UUID.
The XPLC service manager interface.
Definition: new.h:28
virtual IObject * resolve(const char *)
Given a moniker string, return the IObject it refers to, or NULL if no objects match.
Definition: new.cc:36
Various utility functions, macros and templates.
#define UUID_MAP_END
Marks the end of an interface map.
Definition: utils.h:80
#define UUID_MAP_BEGIN(component)
Start the interface map for "component".
Definition: utils.h:63
#define UUID_MAP_ENTRY(iface)
Add an entry to an interface map.
Definition: utils.h:68