Documentation for OpenFLUID 2.2.0
SimulatorRegistry.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file SimulatorRegistry.hpp
35 
36  @author Aline LIBRES <libres@supagro.inra.fr>
37  @author Jean-Christophe Fabre <jean-christophe.fabre@inra.fr>
38  @author Armel THÖNI <armel.thoni@inrae.fr>
39 */
40 
41 
42 #ifndef __OPENFLUID_MACHINE_SIMULATORREGISTRY_HPP__
43 #define __OPENFLUID_MACHINE_SIMULATORREGISTRY_HPP__
44 
45 
51 
52 
53 namespace openfluid { namespace machine {
54 
55 
56 // =====================================================================
57 // =====================================================================
58 
59 
61 {
62  public:
63 
64  /**
65  The method used by the generator to produce the variable
66  */
69 
70  /**
71  The triplets of the produced variable
72  */
74 
75  /**
76  The type of the produced variable (at scalar level)
77  */
79 
80  /**
81  The dmensions of the produced variable.
82  */
84 };
85 
86 
87 // =====================================================================
88 // =====================================================================
89 
90 
91 class OPENFLUID_API SimulatorRegistry : public WareRegistry<openfluid::ware::SimulatorSignature>
92 {
93 
95 
96 
97  private:
98 
99  WaresByID_t m_Generators;
100 
101 
103 
104  WareContainer<openfluid::ware::SimulatorSignature> createWareContainer() const
105  {
107  }
108 
109  WareContainer<openfluid::ware::SimulatorSignature> createGeneratorContainer() const
110  {
112  }
113 
114 
115  public:
116 
117  /**
118  Loads a simulator ware and adds it in the registry if everything went fine
119  @param[in] ID the ID of the ware to load
120  @return true if the wares is successfully added
121  */
123 
124  /**
125  Automatically discovers simulators wares (plugins and ghosts) and adds it in the registry,
126  optionally filtered on IDs using a given pattern
127  @param[in] IDPattern the pattern to filter the wares on ID. Default is empty (no filtering)
128  */
129  void discoverWares(const std::string IDPattern = "");
130 
131  /**
132  Automatically discovers simulators wares (plugins and optionnaly ghosts) and adds it in the registry,
133  optionally filtered on IDs using a given pattern
134  @param[in] WithGhosts enable/disable the search for ghosts simulators
135  @param[in] IDPattern the pattern to filter the wares on ID. Default is empty (no filtering)
136  */
137  void discoverWares(bool WithGhosts, const std::string IDPattern = "");
138 
139  /**
140  Creates a generator and adds it in the registry if everything went fine
141  @param[in] Specs the specifications of the generator to create
142  @return the ID of the generator if successfully added, an empty string otherwise
143  */
145 
146  /**
147  Returns the container of the generator given by its ID
148  @param[in] ID The ID of the ware
149  @return The container of the requested generator, an invalid container if not found
150  */
153 
154  /**
155  Returns the container of the simulator ware or the generator given by its ID.
156  It searches first in the available simulators then in the created generators.
157  @param[in] ID The ID of the simulator or generator
158  @return The container of the requested ware, an invalid container if not found
159  */
162 
163  /**
164  Returns true if a generator already exists with the given ID
165  @param[in] ID The ID of the generator
166  @return true if the generator exists
167  */
169  {
170  return (m_Generators.find(ID) != m_Generators.end());
171  }
172 
173  /**
174  Returns the created generators, indexed by ID
175  @return an ID-container map of generators
176  */
177  const WaresByID_t& generators() const
178  {
179  return m_Generators;
180  }
181 
182  /**
183  Clears the generators stored in the registry
184  */
186  {
187  m_Generators.clear();
188  }
189 
190  /**
191  Clears the registry (simulators and generators)
192  */
193  void clear()
194  {
195  clearWares();
196  clearGenerators();
197  }
198 
199 };
200 
201 
202 } } //namespaces
203 
204 #endif /* __OPENFLUID_MACHINE_SIMULATORREGISTRY_HPP__ */
#define OPENFLUID_SINGLETON_DEFINITION(T)
Definition: SingletonMacros.hpp:55
Definition: Dimensions.hpp:53
Type
Definition: Value.hpp:66
@ DOUBLE
Definition: Value.hpp:66
GeneratorMethod
Definition: GeneratorDescriptor.hpp:58
Definition: SimulatorRegistry.hpp:61
openfluid::tools::UnitVarTriplets_t VarTriplets
Definition: SimulatorRegistry.hpp:73
Definition: SimulatorRegistry.hpp:92
bool addWare(const openfluid::ware::WareID_t &ID)
void discoverWares(bool WithGhosts, const std::string IDPattern="")
const WareContainer< openfluid::ware::SimulatorSignature > & generatorContainer(const openfluid::ware::WareID_t &ID) const
const WaresByID_t & generators() const
Definition: SimulatorRegistry.hpp:177
bool hasGenerator(const openfluid::ware::WareID_t &ID) const
Definition: SimulatorRegistry.hpp:168
void discoverWares(const std::string IDPattern="")
void clearGenerators()
Definition: SimulatorRegistry.hpp:185
void clear()
Definition: SimulatorRegistry.hpp:193
openfluid::ware::WareID_t addGenerator(const GeneratorSpecs &Specs)
const WareContainer< openfluid::ware::SimulatorSignature > & wareOrGeneratorContainer(const openfluid::ware::WareID_t &ID) const
Definition: WareContainer.hpp:62
Definition: WareRegistry.hpp:51
std::map< openfluid::ware::WareID_t, WareContainer< openfluid::ware::SimulatorSignature > > WaresByID_t
Definition: WareRegistry.hpp:57
#define OPENFLUID_API
Definition: dllexport.hpp:86
std::vector< ClassIDVar > UnitVarTriplets_t
Definition: VarHelpers.hpp:169
std::string WareID_t
Definition: TypeDefs.hpp:49
Definition: ApplicationException.hpp:47