WvStreams
xplc.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * XPLC - Cross-Platform Lightweight Components
00004  * Copyright (C) 2000-2003, Pierre Phaneuf
00005  * Copyright (C) 2002, Net Integration Technologies, Inc.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020  * USA
00021  *
00022  * As a special exception, you may use this file as part of a free
00023  * software library without restriction.  Specifically, if other files
00024  * instantiate templates or use macros or inline functions from this
00025  * file, or you compile this file and link it with other files to
00026  * produce an executable, this file does not by itself cause the
00027  * resulting executable to be covered by the GNU Lesser General Public
00028  * License.  This exception does not however invalidate any other
00029  * reasons why the executable file might be covered by the GNU Lesser
00030  * General Public License.
00031  */
00032 
00033 #ifndef __XPLC_XPLC_H__
00034 #define __XPLC_XPLC_H__
00035 
00036 #if defined(__GNUC__) && __GNUC__ > 3
00037 # pragma GCC system_header
00038 #endif
00039 
00045 #include <xplc/core.h>
00046 #include <xplc/utils.h>
00047 #include <xplc/ptr.h>
00048 
00055 class XPLC {
00056 private:
00057   xplc_ptr<IServiceManager> servmgr;
00058 public:
00059   XPLC(): servmgr(XPLC_getServiceManager()) {}
00064   XPLC(IServiceManager* _servmgr): servmgr(do_addRef(_servmgr)) {}
00065 
00069   void addModuleDirectory(const char* directory);
00070 
00075   IObject* get(const UUID& uuid) {
00076     return servmgr->getObject(uuid);
00077   }
00082   template<class Interface>
00083   Interface* get(const UUID& uuid) {
00084     return mutate<Interface>(servmgr->getObject(uuid));
00085   }
00086 
00092   IObject* create(const UUID& cid);
00097   template<class Interface>
00098   Interface* create(const UUID& cid) {
00099     return mutate<Interface>(create(cid));
00100   }
00101 
00107   IObject* create(const char*);
00112   template<class Interface>
00113   Interface* create(const char* aMoniker) {
00114     return mutate<Interface>(create(aMoniker));
00115   }
00116 };
00117 
00118 #endif /* __XPLC_XPLC_H__ */