Documentation for OpenFLUID 2.2.2
Loading...
Searching...
No Matches
SimulatorRegistry.hpp
Go to the documentation of this file.
1/*
2
3 This file is part of OpenFLUID software
4 Copyright(c) 2021-2026, INRAE
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
53namespace 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
77 */
79};
80
81
82// =====================================================================
83// =====================================================================
84
85
86class OPENFLUID_API SimulatorRegistry : public WareRegistry<openfluid::ware::SimulatorSignature>
87{
88
90
91
92 private:
93
94 WaresByID_t m_Generators;
95
96
98
100 {
102 }
103
104 WareContainer<openfluid::ware::SimulatorSignature> createGeneratorContainer() const
105 {
107 }
108
109
110 public:
111
112 /**
113 Loads a simulator ware and adds it in the registry if everything went fine
114 @param[in] ID the ID of the ware to load
115 @return true if the wares is successfully added
116 */
118
119 /**
120 Automatically discovers simulators wares (plugins and ghosts) and adds it in the registry,
121 optionally filtered on IDs using a given pattern
122 @param[in] IDPattern the pattern to filter the wares on ID. Default is empty (no filtering)
123 */
124 void discoverWares(const std::string IDPattern = "");
125
126 /**
127 Automatically discovers simulators wares (plugins and optionnaly ghosts) and adds it in the registry,
128 optionally filtered on IDs using a given pattern
129 @param[in] WithGhosts enable/disable the search for ghosts simulators
130 @param[in] IDPattern the pattern to filter the wares on ID. Default is empty (no filtering)
131 */
132 void discoverWares(bool WithGhosts, const std::string IDPattern = "");
133
134 /**
135 Creates a generator and adds it in the registry if everything went fine
136 @param[in] Specs the specifications of the generator to create
137 @return the ID of the generator if successfully added, an empty string otherwise
138 */
140
141 /**
142 Returns the container of the generator given by its ID
143 @param[in] ID The ID of the ware
144 @return The container of the requested generator, an invalid container if not found
145 */
148
149 /**
150 Returns the container of the simulator ware or the generator given by its ID.
151 It searches first in the available simulators then in the created generators.
152 @param[in] ID The ID of the simulator or generator
153 @return The container of the requested ware, an invalid container if not found
154 */
157
158 /**
159 Returns true if a generator already exists with the given ID
160 @param[in] ID The ID of the generator
161 @return true if the generator exists
162 */
164 {
165 return (m_Generators.find(ID) != m_Generators.end());
166 }
167
168 /**
169 Returns the created generators, indexed by ID
170 @return an ID-container map of generators
171 */
172 const WaresByID_t& generators() const
173 {
174 return m_Generators;
175 }
176
177 /**
178 Clears the generators stored in the registry
179 */
181 {
182 m_Generators.clear();
183 }
184
185 /**
186 Clears the registry (simulators and generators)
187 */
188 void clear()
189 {
190 clearWares();
191 clearGenerators();
192 }
193
194};
195
196
197} } //namespaces
198
199#endif /* __OPENFLUID_MACHINE_SIMULATORREGISTRY_HPP__ */
#define OPENFLUID_SINGLETON_DEFINITION(T)
Definition SingletonMacros.hpp:55
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:87
bool addWare(const openfluid::ware::WareID_t &ID)
void discoverWares(bool WithGhosts, const std::string IDPattern="")
const WareContainer< openfluid::ware::SimulatorSignature > & wareOrGeneratorContainer(const openfluid::ware::WareID_t &ID) const
bool hasGenerator(const openfluid::ware::WareID_t &ID) const
Definition SimulatorRegistry.hpp:163
void discoverWares(const std::string IDPattern="")
const WaresByID_t & generators() const
Definition SimulatorRegistry.hpp:172
void clearGenerators()
Definition SimulatorRegistry.hpp:180
void clear()
Definition SimulatorRegistry.hpp:188
openfluid::ware::WareID_t addGenerator(const GeneratorSpecs &Specs)
const WareContainer< openfluid::ware::SimulatorSignature > & generatorContainer(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