2 Copyright (C) 2012 Intel Corporation
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef PLUGINLOADER_H
20 #define PLUGINLOADER_H
27 #include "abstractsource.h"
28 #include "abstractsink.h"
29 #include "abstractroutingengine.h"
36 typedef void* create_t(AbstractRoutingEngine*, map<string, string> );
43 PluginLoader(string configFile, AbstractRoutingEngine* routingEngine);
49 std::string errorString();
55 T loadPlugin(string pluginName, map<string, string> config)
57 DebugOut()<<"Loading plugin: "<<pluginName<<endl;
61 mErrorString = lt_dlerror();
62 cerr<<"error initializing libtool: "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl;
68 lt_dlhandle handle = lt_dlopenext(pluginName.c_str());
72 mErrorString = lt_dlerror();
73 cerr<<"error opening plugin: "<<pluginName<<" in "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl;
77 f_create = (create_t *)lt_dlsym(handle, "create");
79 //mErrorString = lt_dlerror();
83 void* obj = f_create(routingEngine, config);
84 return static_cast<T>( obj );
92 std::string mPluginPath;
93 std::string mErrorString;
95 AbstractRoutingEngine* routingEngine;
103 #endif // PLUGINLOADER_H