te::plugin::DefaultFinder Class Reference

A plugin finder that search for plugins in some special directories defined by compile time macros. More...

#include <DefaultFinder.h>

Inheritance diagram for te::plugin::DefaultFinder:
te::plugin::AbstractFinder

Public Member Functions

void addPluginsDir (const std::string &path)
 It adds a new base location where the finder will search for installed plugins. More...
 
 DefaultFinder ()
 Constructor. More...
 
void getDefaultDirs (std::vector< std::string > &dirs) const
 It returns the default plugins directories. More...
 
void getPlugins (boost::ptr_vector< PluginInfo > &plugins)
 This method searches for installed plugins and output the plugins information in the PluginInfo vector. More...
 
const std::vector< std::string > & getPluginsDir () const
 It returns the list of plugins base directories. More...
 
 ~DefaultFinder ()
 Destructor. More...
 

Private Attributes

std::vector< std::string > m_pluginsDir
 The base list of directories to search for plugins. More...
 

Detailed Description

A plugin finder that search for plugins in some special directories defined by compile time macros.

This finder will look recursively for plugins in the specified folders.

See also
AbstractFinder, PluginManager, PluginInfo

Definition at line 48 of file DefaultFinder.h.

Constructor & Destructor Documentation

te::plugin::DefaultFinder::DefaultFinder ( )

Constructor.

te::plugin::DefaultFinder::~DefaultFinder ( )

Destructor.

Member Function Documentation

void te::plugin::DefaultFinder::addPluginsDir ( const std::string &  path)

It adds a new base location where the finder will search for installed plugins.

Parameters
pathA new location to search for plugins. It can be an absolute or relative path.
Exceptions
ExceptionIf you inform an invalid path it will throw an exception.
Note
If the path is already in the list of plugin directories it will be discarted.
void te::plugin::DefaultFinder::getDefaultDirs ( std::vector< std::string > &  dirs) const

It returns the default plugins directories.

This method will generate directory paths in the following order:

  • The current execution directory.
  • A default plugins dir (defined by a macro named TE_DEFAULT_PLUGINS_DIR) under the execution directory
  • The default plugins dir(defined by a macro named TE_DEFAULT_PLUGINS_DIR) under the directory given by an environment (TERRALIB_DIR_ENVIRONMENT_VARIABLE)
  • Under the directory defined by TE_PLUGINS_INSTALL_PATH
  • Iff not found returns an empty string
Parameters
dirsThe default plugin directories (the absolute path) or an empty string if none is found.
void te::plugin::DefaultFinder::getPlugins ( boost::ptr_vector< PluginInfo > &  plugins)
virtual

This method searches for installed plugins and output the plugins information in the PluginInfo vector.

This method performs a recursive search on the base directories extracting all plugins information available on these directories. Actually it looks for XML files with a pre-defined name (TE_DEFAULT_PLUGIN_FILE_NAME) and it will try to get all information available for each plugin.

Parameters
pluginsA vector to output all information about found plugins. The caller will take the ownership of the pointers in the output vector.
Exceptions
ExceptionThis method may throw an exception with something goes wrong during the search.
Note
Notice that the plugins vector may contains information about plugins before an exception occurs. So, it is the caller responsability to check and release any PluginInfo returned by this method in the case of an exception.
If no plugins base dir was set it will implicitly look in the default plugins dir.

Implements te::plugin::AbstractFinder.

const std::vector<std::string>& te::plugin::DefaultFinder::getPluginsDir ( ) const

It returns the list of plugins base directories.

Returns
The list if plugins base directories.

Member Data Documentation

std::vector<std::string> te::plugin::DefaultFinder::m_pluginsDir
private

The base list of directories to search for plugins.

Definition at line 114 of file DefaultFinder.h.


The documentation for this class was generated from the following file: