27 #include "../common/Translator.h"
28 #include "../xml/Reader.h"
29 #include "../xml/ReaderFactory.h"
37 #include <boost/filesystem.hpp>
38 #include <boost/format.hpp>
42 std::vector<std::string> plugins;
44 PluginManager::getInstance().getPlugins(plugins);
46 std::vector<std::string>::reverse_iterator it = plugins.rbegin();
47 std::vector<std::string>::reverse_iterator itend = plugins.rend();
52 if(!PluginManager::getInstance().isLoaded(*it))
59 const PluginInfo& plugin = PluginManager::getInstance().getPlugin(*it);
71 std::vector<std::string> pdependents = PluginManager::getInstance().getDependents(plugin);
73 for(std::size_t i = 0; i < pdependents.size(); ++i)
76 if(!PluginManager::getInstance().isLoaded(plugin))
79 PluginManager::getInstance().unload(plugin);
84 boost::filesystem::path pluginFileName(pluginFilePath);
87 if(boost::filesystem::is_directory(pluginFileName))
91 if(!boost::filesystem::is_regular_file(pluginFileName))
92 throw Exception((boost::format(
TR_PLUGIN(
"The informed plugin file is not valid: %1%.")) % pluginFileName).str());
96 xmlReader->read(pluginFileName.string());
98 if(!xmlReader->next())
99 throw Exception(
TR_PLUGIN(
"Could not read plugin information!"));
102 throw Exception(
TR_PLUGIN(
"The document has problems!"));
104 if(xmlReader->getElementLocalName() !=
"PluginInfo")
105 throw Exception(
TR_PLUGIN(
"The first tag in the document is not 'PluginInfo'!"));
107 std::auto_ptr<PluginInfo> pInfo(
new PluginInfo);
108 *pInfo << *xmlReader;
110 pInfo->m_folder = pluginFileName.parent_path().string();
113 return pInfo.release();
The basic information about a plugin.
The basic information about a plugin.
#define TR_PLUGIN(message)
It marks a string in order to get translated. This is a special mark used in the Plugin module of Ter...
TEPLUGINEXPORT void UnloadAllPluginsFromEngine(const std::string &engine)
It unloads all plugins from a given engine.
Utility functions for dealing with plugins.
An abstract class for TerraLib Plugins.
TEPLUGINEXPORT PluginInfo * GetInstalledPlugin(const std::string &pluginFilePath)
It returns information about a given plugin provided its plugin configuration file name or dir...
static te::xml::Reader * make()
It creates a new XML reader using the dafault implementation.
A singleton for managing plugins.
An exception class for the Plugin module.
std::string m_engine
The type of plugin execution engine: C++, JAVA.
TEPLUGINEXPORT void Unload(const std::string &plugin)
It recursively unload the plugin and any dependent plugins.
#define TE_DEFAULT_PLUGIN_FILE_NAME
The XML file name with plugin information.