00001 /*****************************************************************************
00002 * Author: Valient Gough <vgough@pobox.com>
00003 *
00004 *****************************************************************************
00005 * Copyright (c) 2001, Valient Gough
00006 *
00007 * This library is free software; you can distribute it and/or modify it under
00008 * the terms of the GNU Lesser General Public License (LGPL), as published by
00009 * the Free Software Foundation; either version 2.1 of the License, or (at your
00010 * option) any later version.
00011 *
00012 * This library is distributed in the hope that it will be useful, but WITHOUT
00013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 * FITNESS FOR A PARTICULAR PURPOSE. See the LGPL in the file COPYING for more
00015 * details.
00016 *
00017 */
00018
00019 #ifndef _PluginLoader_incl_
00020 #define _PluginLoader_incl_
00021
00022 #include <rel/SmartPtr.h>
00023
00024 #include <string>
00025
00026 namespace rel
00027 {
00028
00029 class PluginLoader
00030 {
00031 public:
00032 PluginLoader(const std::string &fileName);
00033 ~PluginLoader();
00034
00035 typedef OpaqueValue (*func_t)(const OpaqueValue *);
00036
00037 func_t lookupFunction(const char *funcName);
00038
00039 private:
00040 bool loadPlugin();
00041
00042 struct PluginLoaderImpl *impl;
00043 };
00044
00045 class PluginEntryPoint
00046 {
00047 public:
00048 PluginEntryPoint(const std::string &entryPointName,
00049 const SmartPtr<PluginLoader> &plugin);
00050 ~PluginEntryPoint();
00051
00052 bool execute(const OpaqueValue *args, OpaqueValue *output);
00053
00054 private:
00055 struct PluginEntryPointImpl *impl;
00056 };
00057
00058
00059 // Redefine how smart pointer interpret is implemented. This makes it so
00060 // that a PluginEntryPoint may be inserted into a map to transparently act
00061 // as a conduit for that plugin call.
00062 template<>
00063 bool smartPtrInterpret<PluginEntryPoint>(PluginEntryPoint *value,
00064 const std::type_info &outputType,
00065 const OpaqueValue *args,
00066 OpaqueValue *output);
00067
00068
00069 } // namespace rel
00070
00071 #endif
00072
1.2.10 written by Dimitri van Heesch,
© 1997-2001