27 #include "../common/Exception.h" 28 #include "../core/lib/Library.h" 29 #include "../core/lib/LibraryManager.h" 30 #include "../core/logger/Logger.h" 31 #include "../core/translator/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: ");
82 std::string errorMessage;
84 boost::filesystem::path pluginFile(libName);
94 errorMessage = 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;
123 errorMessage.clear();
128 errorMessage +=
'\n';
129 errorMessage += pluginFile.string();
134 pluginFile = alternative_paths[i];
136 pluginFile /= libName;
139 errorMessage.clear();
144 errorMessage +=
'\n';
145 errorMessage += pluginFile.string();
148 #if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS 151 pluginFile = alternative_paths[i];
152 pluginFile /=
"Release";
153 pluginFile /= libName;
156 errorMessage.clear();
161 errorMessage +=
'\n';
162 errorMessage += pluginFile.string();
167 pluginFile = alternative_paths[i];
168 pluginFile /=
"Debug";
169 pluginFile /= libName;
172 errorMessage.clear();
177 errorMessage +=
'\n';
178 errorMessage += pluginFile.string();
183 if(!slib->isLoaded())
185 std::string m =
TE_TR(
"Could not find shared library as: ");
186 if (!errorMessage.empty())
187 m = m +
"\n" + errorMessage.c_str();
189 m = m +
' '+
TE_TR(
"described in ") + pInfo.
m_name +
'.';
198 std::string m =
TE_TR(
"Could not find shared library described in ");
206 if(getPluginFptr == NULL)
208 std::string m =
TE_TR(
"Could not find CppPluginGetInstance function into the plugin's code: ");
215 std::auto_ptr<Plugin> cppPlugin(getPluginFptr(pInfo));
217 if(cppPlugin.get() == 0)
219 std::string m =
TE_TR(
"CppPluginGetInstance returned a null plugin instance: ");
std::string m_name
The plugin name: an internal value used to identify the plugin in the system. Must be a unique value...
Plugin *(* GetPluginFPtr)(const PluginInfo &info)
It exports Plugin's access function type.
An abstract class for TerraLib Plugins.
void unload(AbstractPlugin *plugin)
It try to unload the informed plugin.
virtual const PluginInfo & getInfo() const =0
It return the information associated to the 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 class for handling shared libraries (DLLs, SO, DyLibs).
A proxy class for C++ plugins.
std::string m_engine
The type of plugin execution engine: C++, JAVA.
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.
The basic information about a plugin.
static std::string getNativeName(const std::string &name)
Given a shared library name without file extensions, prefixes and nor suffixes it will construct a li...