27 #include "../common/Exception.h"
28 #include "../common/Library.h"
29 #include "../common/LibraryManager.h"
30 #include "../common/Logger.h"
31 #include "../common/Translator.h"
32 #include "../common/PlatformUtils.h"
33 #include "../Defines.h"
46 #include <boost/filesystem.hpp>
55 std::vector<PluginInfo::Resource>::const_iterator it = std::find_if(pInfo.
m_resources.begin(),
61 std::string m =
TE_TR(
"Shared library name not informed for plugin: ");
69 std::string libName = getPluginFileName(it->second);
85 boost::filesystem::path pluginFile(libName);
100 std::vector<std::string> alternative_paths;
102 #if TE_PLATFORM == TE_PLATFORMCODE_APPLE
103 alternative_paths.push_back(
"./");
107 const char* home_dir = getenv(TERRALIB_DIR_VAR_NAME);
110 alternative_paths.push_back(home_dir);
113 alternative_paths.push_back(TERRALIB_INSTALL_PREFIX_PATH);
115 for(std::size_t i = 0; i != alternative_paths.size(); ++i)
119 pluginFile = alternative_paths[i];
120 pluginFile /= libName;
131 pluginFile = alternative_paths[i];
133 pluginFile /= libName;
142 #if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS
145 pluginFile = alternative_paths[i];
146 pluginFile /=
"Release";
147 pluginFile /= libName;
158 pluginFile = alternative_paths[i];
159 pluginFile /=
"Debug";
160 pluginFile /= libName;
171 if(!slib->isLoaded())
173 std::string m =
TE_TR(
"Could not find shared library: ");
182 std::string m =
TE_TR(
"Could not find shared library: ");
190 if(getPluginFptr == NULL)
192 std::string m =
TE_TR(
"Could not find CppPluginGetInstance function into the plugin's code: ");
199 std::auto_ptr<Plugin> cppPlugin(getPluginFptr(pInfo));
201 if(cppPlugin.get() == 0)
203 std::string m =
TE_TR(
"CppPluginGetInstance returned a null plugin instance: ");
A base class for plugin types.
A plugin engine for plugins written in C++.
boost::shared_ptr< Library > LibraryPtr
std::string m_name
The plugin name: an internal value used to identify the plugin in the system. Must be a unique value...
virtual const PluginInfo & getInfo() const =0
It return the information associated to the plugin.
Plugin *(* GetPluginFPtr)(const PluginInfo &info)
It exports Plugin's access function type.
An abstract class for TerraLib Plugins.
A class for handling shared libraries (DLLs, SO, DyLibs).
void unload(AbstractPlugin *plugin)
It try to unload the informed plugin.
static std::string getPluginFileName(const std::string &libName)
This method will help to form the library name wich contains the plugin.
#define TE_TR(message)
It marks a string in order to get translated.
A proxy class for C++ plugins.
std::string m_engine
The type of plugin execution engine: C++, JAVA.
static std::string getNativeName(const std::string &name)
Given a library name without file extensions, prefixes and nor suffixes it will construct a library n...
static LibraryManager & getInstance()
It returns a reference to the singleton instance.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
AbstractPlugin * load(const PluginInfo &pInfo)
It try to create and load the informed plugin.
std::vector< Resource > m_resources
The list of resources used by plugin.
A proxy class for C++ plugins.
The basic information about a plugin.
void add(const std::string &id, const LibraryPtr &l)
It adds a new Library to be managed.
The basic information about a plugin.