OpenIG  2.0.4
cross-platform open-source OpenSceneGraph Image Generator
PluginHost.h
1 //#******************************************************************************
2 //#*
3 //#* Copyright (C) 2015 Compro Computer Services
4 //#* http://openig.compro.net
5 //#*
6 //#* Source available at: https://github.com/CCSI-CSSI/MuseOpenIG
7 //#*
8 //#* This software is released under the LGPL.
9 //#*
10 //#* This software is free software; you can redistribute it and/or modify
11 //#* it under the terms of the GNU Lesser General Public License as published
12 //#* by the Free Software Foundation; either version 2.1 of the License, or
13 //#* (at your option) any later version.
14 //#*
15 //#* This software is distributed in the hope that it will be useful,
16 //#* but WITHOUT ANY WARRANTY; without even the implied warranty of
17 //#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
18 //#* the GNU Lesser General Public License for more details.
19 //#*
20 //#* You should have received a copy of the GNU Lesser General Public License
21 //#* along with this library; if not, write to the Free Software
22 //#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //#*
24 //#* Please direct any questions or comments to the OpenIG Forums
25 //#* Email address: openig@compro.net
26 //#*
27 //#*
28 //#* Please direct any questions or comments to the OpenIG Forums
29 //#* Email address: openig@compro.net
30 //#*
31 //#*
32 //#*****************************************************************************
33 #ifndef PLUGINHOST_H
34 #define PLUGINHOST_H
35 
36 #if defined(OPENIG_SDK)
37  #include <OpenIG-PluginBase/Export.h>
38  #include <OpenIG-PluginBase/Plugin.h>
39  #include <OpenIG-PluginBase/PluginOperation.h>
40 #else
41  #include <Core-PluginBase/Export.h>
42  #include <Core-PluginBase/Plugin.h>
43  #include <Core-PluginBase/PluginOperation.h>
44 #endif
45 
46 #include <osg/ref_ptr>
47 #include <osgDB/DynamicLibrary>
48 
49 #include <string>
50 #include <map>
51 
52 namespace OpenIG {
53  namespace PluginBase {
54 
61  class IGPLUGINCORE_EXPORT PluginHost
62  {
63  public:
70  PluginHost();
71 
78  ~PluginHost();
79 
90  void loadPlugins(const std::string& path, const std::string& configFileName = "");
91 
98  void unloadPlugins();
99 
108  void applyPluginOperation(OpenIG::PluginBase::PluginOperation* operation);
109 
110  typedef std::map< int, osg::ref_ptr<OpenIG::PluginBase::Plugin> > PluginsMap;
111  typedef std::map< int, osg::ref_ptr<OpenIG::PluginBase::Plugin> >::iterator PluginsMapIterator;
112  typedef std::map< int, osg::ref_ptr<OpenIG::PluginBase::Plugin> >::const_iterator PluginsMapConstIterator;
113 
121  const PluginsMap& getPlugins() const
122  {
123  return _plugins;
124  }
125 
126  protected:
127  PluginsMap _plugins;
129  typedef std::map< std::string, osg::ref_ptr<osgDB::DynamicLibrary> > PluginLibrariesMap;
130  typedef std::map< std::string, osg::ref_ptr<osgDB::DynamicLibrary> >::iterator PluginLibrariesMapIterator;
131  typedef std::map< std::string, osg::ref_ptr<osgDB::DynamicLibrary> >::const_iterator PluginLibrariesMapConstIterator;
132 
133  PluginLibrariesMap _pluginLibraries;
143  bool isPlugin(const std::string& fileName) const;
144 
145  };
146  }
147 } // namespace
148 
149 #endif // PLUGINHOST_H
Definition: ImageGenerator.h:62
The PluginOperation class.
Definition: PluginOperation.h:71
The PluginHost class.
Definition: PluginHost.h:61
const PluginsMap & getPlugins() const
Gets all the plugins in order number based std::map.
Definition: PluginHost.h:121
std::map< std::string, osg::ref_ptr< osgDB::DynamicLibrary > > PluginLibrariesMap
The plugin order number based std::map.
Definition: PluginHost.h:129