WvStreams
xplc.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2  *
3  * XPLC - Cross-Platform Lightweight Components
4  * Copyright (C) 2000-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  * 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 #ifndef __XPLC_XPLC_H__
34 #define __XPLC_XPLC_H__
35 
36 #if defined(__GNUC__) && __GNUC__ > 3
37 # pragma GCC system_header
38 #endif
39 
45 #include <xplc/core.h>
46 #include <xplc/utils.h>
47 #include <xplc/ptr.h>
48 
55 class XPLC {
56 private:
58 public:
59  XPLC(): servmgr(XPLC_getServiceManager()) {}
64  XPLC(IServiceManager* _servmgr): servmgr(do_addRef(_servmgr)) {}
65 
69  void addModuleDirectory(const char* directory);
70 
75  IObject* get(const UUID& uuid) {
76  return servmgr->getObject(uuid);
77  }
82  template<class Interface>
83  Interface* get(const UUID& uuid) {
84  return mutate<Interface>(servmgr->getObject(uuid));
85  }
86 
92  IObject* create(const UUID& cid);
97  template<class Interface>
98  Interface* create(const UUID& cid) {
99  return mutate<Interface>(create(cid));
100  }
101 
107  IObject* create(const char*);
112  template<class Interface>
113  Interface* create(const char* aMoniker) {
114  return mutate<Interface>(create(aMoniker));
115  }
116 };
117 
118 #endif /* __XPLC_XPLC_H__ */
IServiceManager
Definition: IServiceManager.h:58
XPLC::create
Interface * create(const UUID &cid)
Templated variant of XPLC::create() that will do a getInterface() for you.
Definition: xplc.h:98
XPLC::XPLC
XPLC(IServiceManager *_servmgr)
Create an XPLC object using an existing service manager reference.
Definition: xplc.h:64
utils.h
do_addRef
T * do_addRef(T *obj)
Used to addRef an object before passing it to something that would otherwise "steal" the reference.
Definition: ptr.h:139
XPLC::create
IObject * create(const UUID &cid)
Object creation helper.
Definition: xplc.cc:53
XPLC
Definition: xplc.h:55
IObject
Definition: IObject.h:65
XPLC::addModuleDirectory
void addModuleDirectory(const char *directory)
Adds a directory to the module loader path.
Definition: xplc.cc:39
XPLC::get
Interface * get(const UUID &uuid)
Templated variant of XPLC::get() that will do a getInterface() for you.
Definition: xplc.h:83
_GUID
The structure underlying UUIDs.
Definition: uuid.h:94
XPLC::create
Interface * create(const char *aMoniker)
Templated variant of XPLC::create(const char*) that will do a getInterface() for you.
Definition: xplc.h:113
xplc_ptr< IServiceManager >
XPLC::get
IObject * get(const UUID &uuid)
Obtain an XPLC object.
Definition: xplc.h:75
ptr.h