diff options
author | Kevron Rees <kevron.m.rees@intel.com> | 2014-10-01 13:28:49 -0700 |
---|---|---|
committer | Kevron Rees <kevron.m.rees@intel.com> | 2014-10-01 13:28:49 -0700 |
commit | cf6939a9cfa4f8639005c7fc84141d616bc7ef1d (patch) | |
tree | de12b9ad1bcfa42fe10a70e77b5aa89dad0c1fa2 | |
parent | 19dba77ebba86f1a424a21624ac62218e3447fcd (diff) | |
download | automotive-message-broker-cf6939a9cfa4f8639005c7fc84141d616bc7ef1d.tar.gz |
removed all libtool usage
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | ambd/pluginloader.cpp | 42 | ||||
-rw-r--r-- | ambd/pluginloader.h | 19 | ||||
-rw-r--r-- | lib/abstractsink.h | 36 |
4 files changed, 48 insertions, 62 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ebd0a8d5..0e9d6591 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,15 +74,6 @@ if(DOXYGEN_FOUND) endif(DOXYGEN_FOUND) endif(enable_docs) -find_library(libtool_LIBRARY ltdl DOC "Libtool libraries") -find_path(libtool_INCLUDE_DIR ltdl.h DOC "Libtool headers") - -if(libtool_LIBRARY) - message(STATUS "libltdl / libtool found") -else(libtool_LIBRARY) - message(FATAL_ERROR "libltdl / libtool missing. please install libltdl / libtool") -endif(libtool_LIBRARY) - find_package(Boost REQUIRED) @@ -92,7 +83,7 @@ pkg_check_modules(json REQUIRED json) add_definitions(-DDBusServiceName="org.automotive.message.broker") set(include_dirs ${libtool_INCLUDE_DIR} ${glib_INCLUDE_DIRS} ${gio_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${json_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/lib) -set(link_libraries -lamb ${libtool_LIBRARY} ${glib_LIBRARIES} ${json_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib) +set(link_libraries -lamb ${glib_LIBRARIES} ${json_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib) if(qtmainloop) message(STATUS "using Qt mainloop") @@ -122,7 +113,7 @@ if(qtmainloop) endif(qtmainloop) if(usebluez5) - add_definitions(-DUSE_BLUEZ5) + add_definitions(-DUSE_BLUEZ5) endif(usebluez5) diff --git a/ambd/pluginloader.cpp b/ambd/pluginloader.cpp index d2470b8c..f821907b 100644 --- a/ambd/pluginloader.cpp +++ b/ambd/pluginloader.cpp @@ -45,12 +45,6 @@ std::string get_file_contents(const char *filename) } PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(NULL), routingEngine(nullptr), mMainLoop(nullptr) { - if(lt_dlinit()) - { - cerr<<"error initializing libtool: "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<lt_dlerror()<<endl; - throw std::runtime_error("Error initializing libtool. Aborting"); - } - DebugOut()<<"Loading config file: "<<configFile<<endl; json_object *rootobject; json_tokener *tokener = json_tokener_new(); @@ -75,7 +69,7 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N // Handle extra characters after parsed object as desired. // e.g. issue an error, parse another object from that point, etc... } - + json_object *coreobject = json_object_object_get(rootobject,"routingEngine"); if (coreobject) { @@ -151,7 +145,7 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N DebugOut()<<"No mainloop specified in config. Using glib by default."<<endl; mMainLoop = new GlibMainLoop(argc,argv); } - + json_object *sourcesobject = json_object_object_get(rootobject,"sources"); if(!sourcesobject) @@ -159,22 +153,22 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N DebugOut()<<"Error getting sources member: "<<endl; throw std::runtime_error("Error getting sources member"); } - + //g_assert(json_reader_is_array(reader)); g_assert(json_object_get_type(sourcesobject)==json_type_array); - - + + array_list *sourceslist = json_object_get_array(sourcesobject); if (!sourceslist) { DebugOut() << "Error getting source list" << endl; throw std::runtime_error("Error getting sources list"); } - + for(int i=0; i < array_list_length(sourceslist); i++) { json_object *obj = (json_object*)array_list_get_idx(sourceslist,i); //This is an object - + std::map<std::string, std::string> configurationMap; json_object_object_foreach(obj, key, val) { @@ -186,7 +180,7 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N string path = configurationMap["path"]; AbstractSource* plugin = loadPlugin<AbstractSource*>(path,configurationMap); - + if(plugin != nullptr) { mSources.push_back(plugin); @@ -195,9 +189,9 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N //json_object_put(sourcesobject); ///read the sinks: - + json_object *sinksobject = json_object_object_get(rootobject,"sinks"); - + if (!sinksobject) { DebugOut() << "Error getting sink object" << endl; @@ -212,8 +206,8 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N DebugOut() << "Error getting sink list" << endl; throw std::runtime_error("Error getting sink list"); } - - + + for(int i=0; i < array_list_length(sinkslist); i++) { json_object *obj = (json_object*)array_list_get_idx(sinkslist,i); @@ -227,7 +221,7 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N configurationMap[key] = valstr; } - + string path = configurationMap["path"]; AbstractSinkManager* plugin = loadPlugin<AbstractSinkManager*>(path, configurationMap); @@ -262,15 +256,13 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N PluginLoader::~PluginLoader() { - for(auto itr = mSinkManagers.begin(); itr != mSinkManagers.end(); itr++) + for(auto i :mSinkManagers) { - delete *itr; + delete i; } - auto handle = openHandles.begin(); - while(handle != openHandles.end()) - lt_dlclose(*handle++); - lt_dlexit(); + for(auto handle : openHandles) + dlclose(handle); } IMainLoop *PluginLoader::mainloop() diff --git a/ambd/pluginloader.h b/ambd/pluginloader.h index bb794b9f..e92dfb38 100644 --- a/ambd/pluginloader.h +++ b/ambd/pluginloader.h @@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include <string> #include <functional> -#include <ltdl.h> #include <dlfcn.h> #include <iostream> @@ -68,6 +67,8 @@ private: ///methods: return nullptr; } + openHandles.push_back(handle); + f_create = (create_t *)dlsym(handle, "create"); if(f_create) @@ -83,17 +84,18 @@ private: ///methods: { DebugOut()<<"Loading plugin: "<<pluginName<<endl; - lt_dlhandle handle = lt_dlopen(pluginName.c_str()); + void* handle = dlopen(pluginName.c_str(), RTLD_LAZY); if(!handle) { - mErrorString = lt_dlerror(); + mErrorString = dlerror(); DebugOut(DebugOut::Error)<<"error opening plugin: "<<pluginName<<" in "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl; return nullptr; } + openHandles.push_back(handle); - m_create = (create_mainloop_t *)lt_dlsym(handle, "create"); + m_create = (create_mainloop_t *)dlsym(handle, "create"); if(m_create) { @@ -107,17 +109,18 @@ private: ///methods: { DebugOut()<<"Loading plugin: "<<pluginName<<endl; - lt_dlhandle handle = lt_dlopenext(pluginName.c_str()); + void* handle = dlopen(pluginName.c_str(), RTLD_LAZY); if(!handle) { - mErrorString = lt_dlerror(); + mErrorString = dlerror(); cerr<<"error opening plugin: "<<pluginName<<" in "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl; return nullptr; } + openHandles.push_back(handle); - r_create = (createRoutingEngine *)lt_dlsym(handle, "create"); + r_create = (createRoutingEngine *)dlsym(handle, "create"); if(r_create) { @@ -145,7 +148,7 @@ private: IMainLoop* mMainLoop; - std::vector<lt_dlhandle> openHandles; + std::vector<void*> openHandles; }; #endif // PLUGINLOADER_H diff --git a/lib/abstractsink.h b/lib/abstractsink.h index 479f2e08..6494adec 100644 --- a/lib/abstractsink.h +++ b/lib/abstractsink.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Intel Corporation + Copyright (C) 2012 Intel Corporation - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -43,9 +43,9 @@ class AbstractSink public: AbstractSink(AbstractRoutingEngine* engine, map<string, string> config); virtual ~AbstractSink(); - + ///Pure virtual methods: - + /*! uuid() is a unique identifier * @return a guid-style unique identifier */ @@ -63,7 +63,7 @@ public: * @arg supportedProperties the new list of supported properties. */ virtual void supportedChanged(const PropertyList & supportedProperties) = 0; - + protected: /*! * \brief routingEngine is the core of AMB. It is used to pass plugin and property information to other plugins @@ -73,14 +73,14 @@ protected: }; -/// TODO: this class actually serves no purpose. +/// TODO: deprecate in 0.13. class AbstractSinkManager { public: - + AbstractSinkManager(AbstractRoutingEngine* engine, map<string, string> config); virtual ~AbstractSinkManager(){} - + protected: AbstractRoutingEngine* routingEngine; map<string, string> configuration; |