GranOO  3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
PlugInManager.hpp
Go to the documentation of this file.
1 // This file is part of GranOO, a workbench for DEM simulation.
2 //
3 // Author(s) : - Damien Andre IRCER/UNILIM, Limoges France
4 // <damien.andre@unilim.fr>
5 // - Jean-luc Charles Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
6 // <jean-luc.charles@ensam.eu>
7 // - Jeremie Girardot Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
8 // <jeremie.girardot@ensam.eu>
9 // - Cedric Hubert LAMIH/UPHF, Valenciennes France
10 // <cedric.hubert@uphf.fr>
11 // - Ivan Iordanoff Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
12 // <ivan.iordanoff@ensam.eu>
13 //
14 // Copyright (C) 2008-2019 D. Andre, JL. Charles, J. Girardot, C. Hubert, I. Iordanoff
15 //
16 // This program is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 // This program is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this program. If not, see <http://www.gnu.org/licenses/>.
28 
29 
30 
31 #ifndef _GranOO_libCore_PlugInManager_hpp_
32 #define _GranOO_libCore_PlugInManager_hpp_
33 
34 #include <string>
35 #include <map>
36 #include <vector>
37 #include <functional>
38 
39 // Class PlugInManager is singleton.
40 // Only one object of type PlugInManager can be instantiate:
41 // constructor is protected, one must use the public static mathod CreateSpecificObject()
42 
43 class TiXmlElement;
44 
45 namespace GranOO3
46 {
47  namespace Core
48  {
49  class PlugIn;
50  class PlugInManager;
51 
52  std::ostream& operator<< (std::ostream &, const PlugInManager &);//Usefull to debug
53 
54 
55 
57  {
58  friend std::ostream& operator<< (std::ostream &, const PlugInManager &);
59 
60  public:
61  static std::string get_plugin_str_key() {return std::string("PlugIn");}
62  static PlugInManager & get();
63 
64  public:
65  //CONSTRUCTORS & DESTRUCTORS
66  virtual ~PlugInManager();
67 
68  //USEFULL
69  std::vector<PlugIn*> read_xml_file(const std::string & xPathParent, bool verbose = false);
70  std::vector<PlugIn*> read_xml_parent_element(const TiXmlElement* el, bool verbose = false);
71  PlugIn* read_xml_element(const TiXmlElement* el, bool verbose = false);
72 
73 
74  template<typename T> std::vector<PlugIn*> read_xml_file_with_parent_property_required(const std::string & xPathParent,
75  const std::string& xmlTag,
76  const T& valueRequired);
77  bool record(const std::string & id, std::function<PlugIn * ()>);
78 
79  private:
80  PlugInManager & operator=(const PlugInManager &); //not allowed
81  PlugInManager(const PlugInManager &); //not allowed
82 
83  PlugInManager();
84  std::map<const std::string, std::function<PlugIn * ()> >& get_map();
85  const std::map<const std::string, std::function<PlugIn * ()> >& get_map() const;
86  std::vector<std::string> get_plugin_list() const;
87 
88  private:
90  std::map<const std::string, std::function<PlugIn * ()> > _the_map;
91  };
92 
93 
94 
95 
96 
97  }
98 }
99 
100 #endif
Definition: PlugIn.hpp:101
Definition: PlugInManager.hpp:57
PlugInManager(const PlugInManager &)
static PlugInManager & get()
Definition: PlugInManager.cpp:45
std::vector< PlugIn * > read_xml_file_with_parent_property_required(const std::string &xPathParent, const std::string &xmlTag, const T &valueRequired)
bool record(const std::string &id, std::function< PlugIn *()>)
Definition: PlugInManager.cpp:133
std::vector< PlugIn * > read_xml_parent_element(const TiXmlElement *el, bool verbose=false)
Definition: PlugInManager.cpp:78
std::vector< std::string > get_plugin_list() const
Definition: PlugInManager.cpp:146
std::map< const std::string, std::function< PlugIn *()> > & get_map()
Definition: PlugInManager.cpp:53
virtual ~PlugInManager()
Definition: PlugInManager.cpp:66
static PlugInManager * _the_plugin_manager
Definition: PlugInManager.hpp:89
std::map< const std::string, std::function< PlugIn *()> > _the_map
Definition: PlugInManager.hpp:90
PlugInManager & operator=(const PlugInManager &)
std::vector< PlugIn * > read_xml_file(const std::string &xPathParent, bool verbose=false)
PlugInManager()
Definition: PlugInManager.cpp:62
friend std::ostream & operator<<(std::ostream &, const PlugInManager &)
Definition: PlugInManager.cpp:70
PlugIn * read_xml_element(const TiXmlElement *el, bool verbose=false)
Definition: PlugInManager.cpp:92
static std::string get_plugin_str_key()
Definition: PlugInManager.hpp:61
std::ostream & operator<<(std::ostream &os, const Color &color)
Definition: Color.cpp:38
Definition: Common.hpp:198