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);
86 std::string errorMessage;
88 boost::filesystem::path pluginFile(libName);
98 errorMessage = libName;
101 if(!slib->isLoaded())
104 std::vector<std::string> alternative_paths;
106 #if TE_PLATFORM == TE_PLATFORMCODE_APPLE
107 alternative_paths.push_back(
"./");
111 const char* home_dir = getenv(TERRALIB_DIR_VAR_NAME);
114 alternative_paths.push_back(home_dir);
117 alternative_paths.push_back(TERRALIB_INSTALL_PREFIX_PATH);
119 for(std::size_t i = 0; i != alternative_paths.size(); ++i)
123 pluginFile = alternative_paths[i];
124 pluginFile /= libName;
127 errorMessage.clear();
132 errorMessage +=
'\n';
133 errorMessage += pluginFile.string();
138 pluginFile = alternative_paths[i];
140 pluginFile /= libName;
143 errorMessage.clear();
148 errorMessage +=
'\n';
149 errorMessage += pluginFile.string();
152 #if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS
155 pluginFile = alternative_paths[i];
156 pluginFile /=
"Release";
157 pluginFile /= libName;
160 errorMessage.clear();
165 errorMessage +=
'\n';
166 errorMessage += pluginFile.string();
171 pluginFile = alternative_paths[i];
172 pluginFile /=
"Debug";
173 pluginFile /= libName;
176 errorMessage.clear();
181 errorMessage +=
'\n';
182 errorMessage += pluginFile.string();
187 if(!slib->isLoaded())
189 std::string m =
TE_TR(
"Could not find shared library as: ");
190 if (!errorMessage.empty())
191 m = m +
"\n" + errorMessage.c_str();
193 m = m +
' '+
TE_TR(
"descried in ") + pInfo.
m_name +
'.';
202 std::string m =
TE_TR(
"Could not find shared library described in ");
210 if(getPluginFptr == NULL)
212 std::string m =
TE_TR(
"Could not find CppPluginGetInstance function into the plugin's code: ");
219 std::auto_ptr<Plugin> cppPlugin(getPluginFptr(pInfo));
221 if(cppPlugin.get() == 0)
223 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.