hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
plugin.hh
Go to the documentation of this file.
1 // Copyright (c) 2019, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of hpp-core.
5 // hpp-core is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-core is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-core. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HPP_CORE_PLUGIN_HH
18 #define HPP_CORE_PLUGIN_HH
19 
20 #include <string>
21 
22 #include <hpp/core/config.hh>
23 #include <hpp/core/fwd.hh>
24 
25 namespace hpp {
26  namespace core {
29 
32  public:
33  const std::string& name () const
34  {
35  return name_;
36  }
37 
38  const std::string& version () const
39  {
40  return version_;
41  }
42 
44  {
45  if (initialized_) return true;
46  initialized_ = impl_initialize (ps);
47  return initialized_;
48  }
49 
50  virtual ~ProblemSolverPlugin () {}
51 
52  protected:
53  virtual bool impl_initialize (ProblemSolverPtr_t ps) = 0;
54 
55  ProblemSolverPlugin (const std::string& name, const std::string& version)
56  : name_ (name), version_ (version), initialized_ (false)
57  {}
58 
59  private:
60  std::string name_, version_;
61  bool initialized_;
62  }; // class ProblemSolver
63 
72 #define HPP_CORE_DEFINE_PLUGIN(PluginClassName) \
73  extern "C" { \
74  ::hpp::core::ProblemSolverPlugin* createProblemSolverPlugin () \
75  { \
76  return new PluginClassName (); \
77  } \
78  }
79 
80  namespace plugin {
86  std::string findPluginLibrary (const std::string& name);
87 
92  bool loadPlugin (const std::string& lib, ProblemSolver* ps);
93  } // namespace plugin
94 
96 
97  } // namespace core
98 } // namespace hpp
99 
100 #endif // HPP_CORE_PLUGIN_HH
Definition: problem-solver.hh:68
bool initialize(ProblemSolverPtr_t ps)
Definition: plugin.hh:43
virtual ~ProblemSolverPlugin()
Definition: plugin.hh:50
const std::string & version() const
Definition: plugin.hh:38
std::string findPluginLibrary(const std::string &name)
bool loadPlugin(const std::string &lib, ProblemSolver *ps)
virtual bool impl_initialize(ProblemSolverPtr_t ps)=0
ProblemSolverPlugin(const std::string &name, const std::string &version)
Definition: plugin.hh:55
const std::string & name() const
Definition: plugin.hh:33
Plugin mechanism to declare new features in ProblemSolver class.
Definition: plugin.hh:31