Builds gum::prm::PRMSystem from gum::prm::o3prm::O3System.
More...
#include <agrum/PRM/o3prm/O3SystemFactory.h>
template<typename GUM_SCALAR>
class gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >
Builds gum::prm::PRMSystem from gum::prm::o3prm::O3System.
- Template Parameters
-
Definition at line 57 of file O3SystemFactory.h.
◆ O3SystemFactory() [1/3]
template<typename GUM_SCALAR >
Definition at line 37 of file O3SystemFactory_tpl.h.
ErrorsContainer * errors__
O3NameSolver< GUM_SCALAR > * solver__
O3SystemFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
PRM< GUM_SCALAR > * prm__
◆ O3SystemFactory() [2/3]
template<typename GUM_SCALAR >
Definition at line 48 of file O3SystemFactory_tpl.h.
ErrorsContainer * errors__
O3NameSolver< GUM_SCALAR > * solver__
O3SystemFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
HashTable< std::string, O3Instance *> nameMap__
PRM< GUM_SCALAR > * prm__
◆ O3SystemFactory() [3/3]
template<typename GUM_SCALAR >
Definition at line 57 of file O3SystemFactory_tpl.h.
59 prm__(std::move(src.prm__)),
ErrorsContainer * errors__
O3NameSolver< GUM_SCALAR > * solver__
O3SystemFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
HashTable< std::string, O3Instance *> nameMap__
PRM< GUM_SCALAR > * prm__
◆ ~O3SystemFactory()
template<typename GUM_SCALAR >
Definition at line 66 of file O3SystemFactory_tpl.h.
O3SystemFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
◆ addAssignments__()
template<typename GUM_SCALAR >
Definition at line 143 of file O3SystemFactory_tpl.h.
146 const auto& real_sys =
prm__->getSystem(sys.name().label());
148 for (
auto& ass: sys.assignments()) {
149 auto leftInstance = ass.leftInstance().label();
150 auto leftReference = ass.leftReference().label();
151 auto rightInstance = ass.rightInstance().label();
153 if (ass.leftIndex().value() > -1 && real_sys.isArray(leftInstance)) {
154 std::stringstream sBuff;
155 sBuff << leftInstance <<
"[" << ass.leftIndex().value() <<
"]";
156 leftInstance = sBuff.str();
159 if (ass.rightIndex().value() > -1 && real_sys.isArray(rightInstance)) {
160 std::stringstream sBuff;
161 sBuff << rightInstance <<
"[" << ass.rightIndex().value() <<
"]";
162 rightInstance = sBuff.str();
165 factory.setReferenceSlot(leftInstance, leftReference, rightInstance);
PRM< GUM_SCALAR > * prm__
◆ addIncrements__()
template<typename GUM_SCALAR >
Definition at line 170 of file O3SystemFactory_tpl.h.
173 const auto& real_sys =
prm__->getSystem(sys.name().label());
174 for (
auto& inc: sys.increments()) {
175 auto leftInstance = inc.leftInstance().label();
176 auto leftReference = inc.leftReference().label();
177 auto rightInstance = inc.rightInstance().label();
179 if (inc.leftIndex().value() > -1 && real_sys.isArray(leftInstance)) {
180 std::stringstream sBuff;
181 sBuff << leftInstance <<
"[" << inc.leftIndex().value() <<
"]";
182 leftInstance = sBuff.str();
185 if (inc.rightIndex().value() > -1 && real_sys.isArray(rightInstance)) {
186 std::stringstream sBuff;
187 sBuff << rightInstance <<
"[" << inc.rightIndex().value() <<
"]";
188 rightInstance = sBuff.str();
191 factory.setReferenceSlot(leftInstance, leftReference, rightInstance);
PRM< GUM_SCALAR > * prm__
◆ addInstances__()
template<typename GUM_SCALAR >
Definition at line 119 of file O3SystemFactory_tpl.h.
122 for (
auto& i: sys.instances()) {
123 if (i.parameters().size() > 0) {
125 for (
auto& p: i.parameters()) {
126 params.
insert(p.name().label(), (
double)p.value().value());
128 factory.addInstance(i.type().label(), i.name().label(), params);
131 if (i.size().value() > 1) {
132 factory.addArray(i.type().label(),
136 factory.addInstance(i.type().label(), i.name().label());
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
◆ build()
template<typename GUM_SCALAR >
Definition at line 95 of file O3SystemFactory_tpl.h.
96 PRMFactory< GUM_SCALAR > factory(
prm__);
100 nameMap__ = HashTable< std::string, O3Instance* >();
103 factory.startSystem(sys->name().label());
111 }
catch (FatalError&) {
112 O3PRM_SYSTEM_INSTANTIATION_FAILED(*sys, *
errors__);
ErrorsContainer * errors__
bool checkSystem__(O3System &sys)
void addAssignments__(PRMFactory< GUM_SCALAR > &factory, O3System &sys)
void addIncrements__(PRMFactory< GUM_SCALAR > &factory, O3System &sys)
void addInstances__(PRMFactory< GUM_SCALAR > &factory, O3System &sys)
HashTable< std::string, O3Instance *> nameMap__
PRM< GUM_SCALAR > * prm__
◆ checkAssignments__()
template<typename GUM_SCALAR >
Definition at line 273 of file O3SystemFactory_tpl.h.
274 for (
auto& ass: sys.assignments()) {
280 if (!
nameMap__.exists(ass.leftInstance().label())) {
281 O3PRM_SYSTEM_INSTANCE_NOT_FOUND(ass.leftInstance(), *
errors__);
285 auto i =
nameMap__[ass.leftInstance().label()];
286 const auto& type =
prm__->getClass(i->type().label());
287 const auto& ref = ass.leftReference().label();
289 if (!(type.exists(ass.leftReference().label())
292 O3PRM_SYSTEM_REFERENCE_NOT_FOUND(ass.leftReference(),
299 =
static_cast< const PRMReferenceSlot< GUM_SCALAR >&
>(type.get(ref));
301 if (!
nameMap__.exists(ass.rightInstance().label())) {
302 O3PRM_SYSTEM_INSTANCE_NOT_FOUND(ass.rightInstance(), *
errors__);
306 if (real_ref.isArray()
307 &&
nameMap__[ass.rightInstance().label()]->size().value() == 0) {
308 O3PRM_SYSTEM_NOT_AN_ARRAY(ass.rightInstance(), *
errors__);
312 if ((!real_ref.isArray())
313 &&
nameMap__[ass.rightInstance().label()]->size().value() > 0
314 && ass.rightIndex().value() == -1) {
315 O3PRM_SYSTEM_NOT_AN_ARRAY(ass.leftReference(), *
errors__);
ErrorsContainer * errors__
static INLINE bool isReferenceSlot(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMReferenceSlot.
HashTable< std::string, O3Instance *> nameMap__
PRM< GUM_SCALAR > * prm__
◆ checkIncrements__()
template<typename GUM_SCALAR >
Definition at line 323 of file O3SystemFactory_tpl.h.
324 for (
auto& inc: sys.increments()) {
330 if (!
nameMap__.exists(inc.leftInstance().label())) {
331 O3PRM_SYSTEM_INSTANCE_NOT_FOUND(inc.leftInstance(), *
errors__);
335 auto i =
nameMap__[inc.leftInstance().label()];
336 const auto& type =
prm__->getClass(i->type().label());
337 const auto& ref = inc.leftReference().label();
339 if (!(type.exists(inc.leftReference().label())
342 O3PRM_SYSTEM_REFERENCE_NOT_FOUND(inc.leftReference(),
349 =
static_cast< const PRMReferenceSlot< GUM_SCALAR >&
>(type.get(ref));
351 if (!real_ref.isArray()) {
352 O3PRM_SYSTEM_NOT_AN_ARRAY(inc.leftReference(), *
errors__);
ErrorsContainer * errors__
static INLINE bool isReferenceSlot(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMReferenceSlot.
HashTable< std::string, O3Instance *> nameMap__
PRM< GUM_SCALAR > * prm__
◆ checkInstance__()
template<typename GUM_SCALAR >
Definition at line 206 of file O3SystemFactory_tpl.h.
207 for (
auto& i: sys.instances()) {
208 if (!
solver__->resolveClass(i.type())) {
return false; }
210 const auto& type =
prm__->getClass(i.type().label());
211 if (type.parameters().size() > 0) {
215 if (
nameMap__.exists(i.name().label())) {
216 O3PRM_SYSTEM_DUPLICATE_INSTANCE(i, *
errors__);
ErrorsContainer * errors__
bool checkParameters__(const PRMClass< GUM_SCALAR > &type, const O3Instance &inst)
O3NameSolver< GUM_SCALAR > * solver__
HashTable< std::string, O3Instance *> nameMap__
PRM< GUM_SCALAR > * prm__
◆ checkParameters__()
template<typename GUM_SCALAR >
Definition at line 227 of file O3SystemFactory_tpl.h.
230 for (
const auto& param: inst.parameters()) {
231 if (!type.exists(param.name().label())) {
232 O3PRM_SYSTEM_PARAMETER_NOT_FOUND(param, *
errors__);
237 type.get(param.name().label()))) {
238 O3PRM_SYSTEM_NOT_A_PARAMETER(param, *
errors__);
242 const auto& type_param
243 =
static_cast< const PRMParameter< GUM_SCALAR >&
>(
244 type.get(param.name().label()));
246 switch (type_param.valueType()) {
247 case PRMParameter< GUM_SCALAR >::ParameterType::INT: {
248 if (!param.isInteger()) {
249 O3PRM_SYSTEM_PARAMETER_NOT_INT(param, *
errors__);
255 case PRMParameter< GUM_SCALAR >::ParameterType::REAL: {
256 if (param.isInteger()) {
257 O3PRM_SYSTEM_PARAMETER_NOT_FLOAT(param, *
errors__);
264 GUM_ERROR(FatalError,
"unknown parameter type");
ErrorsContainer * errors__
static INLINE bool isParameter(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMParameter.
#define GUM_ERROR(type, msg)
◆ checkSystem__()
template<typename GUM_SCALAR >
Definition at line 196 of file O3SystemFactory_tpl.h.
bool checkInstance__(O3System &sys)
bool checkIncrements__(O3System &sys)
bool checkAssignments__(O3System &sys)
◆ operator=() [1/2]
template<typename GUM_SCALAR >
Definition at line 72 of file O3SystemFactory_tpl.h.
74 if (
this == &src) {
return *
this; }
ErrorsContainer * errors__
O3NameSolver< GUM_SCALAR > * solver__
PRM< GUM_SCALAR > * prm__
◆ operator=() [2/2]
template<typename GUM_SCALAR >
Definition at line 84 of file O3SystemFactory_tpl.h.
86 if (
this == &src) {
return *
this; }
87 prm__ = std::move(src.prm__);
ErrorsContainer * errors__
O3NameSolver< GUM_SCALAR > * solver__
PRM< GUM_SCALAR > * prm__
◆ errors__
template<typename GUM_SCALAR >
◆ nameMap__
template<typename GUM_SCALAR >
◆ o3_prm__
template<typename GUM_SCALAR >
◆ prm__
template<typename GUM_SCALAR >
◆ solver__
template<typename GUM_SCALAR >
The documentation for this class was generated from the following files: