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);
48 std::string errorString();
54 T loadPlugin(string pluginName, map<string, string> config)
56 DebugOut()<<"Loading plugin: "<<pluginName<<endl;
60 mErrorString = lt_dlerror();
61 cerr<<"error initializing libtool: "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl;
67 lt_dlhandle handle = lt_dlopenext(pluginName.c_str());
71 mErrorString = lt_dlerror();
72 cerr<<"error opening plugin: "<<pluginName<<" in "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl;
76 f_create = (create_t *)lt_dlsym(handle, "create");
78 //mErrorString = lt_dlerror();
82 void* obj = f_create(routingEngine, config);
83 return static_cast<T>( obj );
91 std::string mPluginPath;
92 std::string mErrorString;
94 AbstractRoutingEngine* routingEngine;
102 #endif // PLUGINLOADER_H