DefaultFinder.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/plugin/DefaultFinder.h
22 
23  \brief A plugin finder that search for plugins in some special directories defined by compile time macros.
24 */
25 
26 #ifndef __TERRALIB_PLUGIN_INTERNAL_DEFAULTFINDER_H
27 #define __TERRALIB_PLUGIN_INTERNAL_DEFAULTFINDER_H
28 
29 // TerraLib
30 #include "AbstractFinder.h"
31 
32 // STL
33 #include <string>
34 
35 namespace te
36 {
37  namespace plugin
38  {
39  /*!
40  \class DefaultFinder
41 
42  \brief A plugin finder that search for plugins in some special directories defined by compile time macros.
43 
44  This finder will look recursively for plugins in the specified folders.
45 
46  \sa AbstractFinder, PluginManager, PluginInfo
47  */
49  {
50  public:
51 
52  /*! \brief Constructor. */
53  DefaultFinder();
54 
55  /*! \brief Destructor. */
56  ~DefaultFinder();
57 
58  /*!
59  \brief It returns the default plugins directories.
60 
61  This method will generate directory paths in the following order:
62  <ul>
63  <li> The current execution directory.
64  <li> A default plugins dir (defined by a macro named TE_DEFAULT_PLUGINS_DIR) under the execution directory</li>
65  <li> The default plugins dir(defined by a macro named TE_DEFAULT_PLUGINS_DIR) under the directory given by an environment (TERRALIB_DIR_ENVIRONMENT_VARIABLE)</li>
66  <li> Under the directory defined by TE_PLUGINS_INSTALL_PATH
67  <li> Iff not found returns an empty string</li>
68  </ul>
69 
70  \param dirs The default plugin directories (the absolute path) or an empty string if none is found.
71  */
72  void getDefaultDirs( std::vector< std::string >& dirs ) const;
73 
74  /*!
75  \brief It adds a new base location where the finder will search for installed plugins.
76 
77  \param path A new location to search for plugins. It can be an absolute or relative path.
78 
79  \exception Exception If you inform an invalid path it will throw an exception.
80 
81  \note If the path is already in the list of plugin directories it will be discarted.
82  */
83  void addPluginsDir(const std::string& path);
84 
85  /*!
86  \brief It returns the list of plugins base directories.
87 
88  \return The list if plugins base directories.
89  */
90  const std::vector<std::string>& getPluginsDir() const;
91 
92  /*!
93  \brief This method searches for installed plugins and output the plugins information in the PluginInfo vector.
94 
95  This method performs a recursive search on the base directories extracting all plugins information available on these directories.
96  Actually it looks for XML files with a pre-defined name (TE_DEFAULT_PLUGIN_FILE_NAME) and it will
97  try to get all information available for each plugin.
98 
99  \param plugins A vector to output all information about found plugins. The caller
100  will take the ownership of the pointers in the output vector.
101 
102  \exception Exception This method may throw an exception with something goes wrong during the search.
103 
104  \note Notice that the plugins vector may contains information about plugins before an exception occurs.
105  So, it is the caller responsability to check and release any PluginInfo returned by this method
106  in the case of an exception.
107 
108  \note If no plugins base dir was set it will implicitly look in the default plugins dir.
109  */
110  void getPlugins(boost::ptr_vector<PluginInfo>& plugins);
111 
112  private:
113 
114  std::vector<std::string> m_pluginsDir; //!< The base list of directories to search for plugins.
115  };
116 
117  } // end namespace plugin
118 } // end namespace te
119 
120 #endif // __TERRALIB_PLUGIN_INTERNAL_DEFAULTFINDER_H
121 
122 
123 
The AbstractFinder class allows applications to extend how PluginManager can search for plugins...
A plugin finder that search for plugins in some special directories defined by compile time macros...
Definition: DefaultFinder.h:48
The AbstractFinder class allows applications to extend how PluginManager can search for plugins...
std::vector< std::string > m_pluginsDir
The base list of directories to search for plugins.
URI C++ Library.
#define TEPLUGINEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:120