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 
33 NewMoniker::~NewMoniker() {
34 }
35 
36 IObject* 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 
IServiceManager
Definition: IServiceManager.h:58
IServiceHandler::getObject
virtual IObject * getObject(const UUID &)=0
Get the object corresponding to the given UUID.
UUID_MAP_ENTRY
#define UUID_MAP_ENTRY(iface)
Add an entry to an interface map.
Definition: utils.h:68
UUID_MAP_BEGIN
#define UUID_MAP_BEGIN(component)
Start the interface map for "component".
Definition: utils.h:63
IFactory::createObject
virtual IObject * createObject()=0
Creates an object.
IFactory
Definition: IFactory.h:37
utils.h
IMoniker
Definition: IMoniker.h:50
IObject::release
virtual unsigned int release()=0
Indicate that you are finished using this object.
NewMoniker
Definition: new.h:28
UUID_MAP_END
#define UUID_MAP_END
Marks the end of an interface map.
Definition: utils.h:80
IObject
Definition: IObject.h:65
NewMoniker::resolve
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
IMoniker::resolve
virtual IObject * resolve(const char *moniker)=0
Given a moniker string, return the IObject it refers to, or NULL if no objects match.