soma-io  5.1.2
plugin.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef SOMAIO_PLUGIN_PLUGIN_H
35 #define SOMAIO_PLUGIN_PLUGIN_H
36 
37 #include <string>
38 #include <set>
39 #include <list>
40 
41 namespace carto
42 {
43 
44  class Plugin
45  {
46  friend class PluginManager;
47 
48  public:
49  Plugin();
50  virtual ~Plugin();
51  virtual std::string name() const;
52 
53  private:
54  virtual void initialize();
55  };
56 
58  {
59  public:
62  void registerPlugin( Plugin* p );
64  std::set<Plugin*> plugins() const;
66 
67  private:
68  struct PluginManagerPrivate;
69  PluginManagerPrivate *d;
70  };
71 
72 
74  {
75  public:
77  static void load( int verboseLevel = -1, bool forcereload = false );
79  static void loadPluginFile( const std::string & file,
80  const std::string & version = "",
81  int verboseLevel = 0 );
82  struct PluginFile
83  {
84  PluginFile( const std::string & file, const std::string & ver = "" );
85  bool operator == ( const PluginFile & pf ) const
86  { return filename == pf.filename && version == pf.version; }
87  std::string filename;
88  std::string version;
89  bool loaded;
90  };
97  static std::list<PluginFile> & pluginFiles();
98  };
99 
100 }
101 
102 #endif
103 
static void loadPluginFile(const std::string &file, const std::string &version="", int verboseLevel=0)
load a specific plugin file (in Python format)
static void load(int verboseLevel=-1, bool forcereload=false)
load the complete pluginFiles list
static std::list< PluginFile > & pluginFiles()
static list of plugin files to be loaded.
std::set< Plugin * > plugins() const
void unregisterPlugin(Plugin *p)
static PluginManager & singleton()
void registerPlugin(Plugin *p)
virtual std::string name() const
virtual ~Plugin()
bool operator==(const PluginFile &pf) const
Definition: plugin.h:85
PluginFile(const std::string &file, const std::string &ver="")