aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
gum::prm::o3prm::O3ClassFactory< GUM_SCALAR > Class Template Reference

Builds gum::prm::Class from gum::prm::o3prm::O3Class. More...

#include <agrum/PRM/o3prm/O3ClassFactory.h>

Collaboration diagram for gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >:
[legend]

Public Member Functions

 O3ClassFactory (PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
 O3ClassFactory (const O3ClassFactory< GUM_SCALAR > &src)
 O3ClassFactory (O3ClassFactory< GUM_SCALAR > &&src)
 ~O3ClassFactory ()
O3ClassFactory< GUM_SCALAR > & operator= (const O3ClassFactory< GUM_SCALAR > &src)
O3ClassFactory< GUM_SCALAR > & operator= (O3ClassFactory< GUM_SCALAR > &&src)
void buildClasses ()
void buildImplementations ()
void buildParameters ()
void buildReferenceSlots ()
void declareAggregates ()
void completeAggregates ()
void declareAttributes ()
void completeAttributes ()

Private Member Functions

Checking classes
void _setO3ClassCreationOrder_ ()
bool _checkAndAddNodesToDag_ ()
bool _checkAndAddArcsToDag_ ()
bool _checkO3Classes_ ()
Checking Implementations
bool _checkImplementation_ (O3Class &c)
bool _checkImplementation_ (O3Class &c, O3Label &i, HashTable< std::string, O3Attribute * > &attrMap, HashTable< std::string, O3Aggregate * > &aggMap, HashTable< std::string, O3ReferenceSlot * > &refMap)
bool _checkImplementation_ (O3Label &o3_type, const PRMType &type)
bool _checkImplementation_ (O3Label &o3_type, const PRMClassElementContainer< GUM_SCALAR > &type)
Checking and Adding Paramteters
void _addParameters_ (PRMFactory< GUM_SCALAR > &factory, O3Class &c)
Checking and adding Reference Slots
void _addReferenceSlots_ (O3Class &c)
bool _checkReferenceSlot_ (O3Class &c, O3ReferenceSlot &ref)
Checking and adding Attributes
void _declareAttribute_ (O3Class &c)
bool _checkAttributeForDeclaration_ (O3Class &o3_c, O3Attribute &attr)
void _completeAttribute_ (PRMFactory< GUM_SCALAR > &factory, O3Class &c)
bool _checkAttributeForCompletion_ (const O3Class &o3_c, O3Attribute &attr)
bool _checkParent_ (const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
bool _checkLocalParent_ (const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
bool _checkRemoteParent_ (const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &prnt)
bool _checkRawCPT_ (const PRMClass< GUM_SCALAR > &c, O3RawCPT &attr)
bool _checkRuleCPT_ (const PRMClass< GUM_SCALAR > &c, O3RuleCPT &attr)
bool _checkLabelsNumber_ (const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
bool _checkLabelsValues_ (const PRMClass< GUM_SCALAR > &c, const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
void _addParamsToForms_ (const HashTable< std::string, const PRMParameter< GUM_SCALAR > * > &scope, O3RuleCPT::O3Rule &rule)
bool _checkRuleCPTSumsTo1_ (const PRMClass< GUM_SCALAR > &c, const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
Utility methods
const PRMClassElement< GUM_SCALAR > * _resolveSlotChain_ (const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain)
bool _checkSlotChainLink_ (const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain, std::string_view s)
Checking and adding Aggregates
void _declareAggregates_ (O3Class &c)
void _completeAggregates_ (PRMFactory< GUM_SCALAR > &factory, O3Class &c)
bool _checkAggregateForDeclaration_ (O3Class &o3class, O3Aggregate &agg)
bool _checkAggregateForCompletion_ (O3Class &o3class, O3Aggregate &agg)
const PRMType * _checkAggParents_ (O3Class &o3class, O3Aggregate &agg)
bool _checkAggTypeLegality_ (O3Class &o3class, O3Aggregate &agg)
bool _checkAggParameters_ (O3Class &o3class, O3Aggregate &agg, const PRMType *t)
bool _checkParametersNumber_ (O3Aggregate &agg, Size n)
bool _checkParameterValue_ (O3Aggregate &agg, const gum::prm::PRMType &t)

Private Attributes

PRM< GUM_SCALAR > * _prm_
O3PRM * _o3_prm_
O3NameSolver< GUM_SCALAR > * _solver_
ErrorsContainer * _errors_
HashTable< std::string, gum::NodeId > _nameMap_
HashTable< std::string, O3Class * > _classMap_
HashTable< NodeId, O3Class * > _nodeMap_
DAG _dag_
std::vector< O3Class * > _o3Classes_

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >

Builds gum::prm::Class from gum::prm::o3prm::O3Class.

Template Parameters
GUM_SCALARThe scalar type used by the gum::prm:PRM.

Definition at line 74 of file O3ClassFactory.h.

Constructor & Destructor Documentation

◆ O3ClassFactory() [1/3]

template<GUM_Numeric GUM_SCALAR>
gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::O3ClassFactory ( PRM< GUM_SCALAR > & prm,
O3PRM & o3_prm,
O3NameSolver< GUM_SCALAR > & solver,
ErrorsContainer & errors )

Definition at line 60 of file O3ClassFactory_tpl.h.

63 :
66 }
Builds gum::prm::Class from gum::prm::o3prm::O3Class.
O3NameSolver< GUM_SCALAR > * _solver_
O3ClassFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)

References O3ClassFactory(), _errors_, _o3_prm_, _prm_, and _solver_.

Referenced by O3ClassFactory(), O3ClassFactory(), O3ClassFactory(), ~O3ClassFactory(), gum::prm::o3prm::O3prmReader< GUM_SCALAR >::_readStream_(), operator=(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ O3ClassFactory() [2/3]

template<GUM_Numeric GUM_SCALAR>
gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::O3ClassFactory ( const O3ClassFactory< GUM_SCALAR > & src)

Definition at line 69 of file O3ClassFactory_tpl.h.

References O3ClassFactory(), _classMap_, _dag_, _errors_, _nameMap_, _nodeMap_, _o3_prm_, _o3Classes_, _prm_, and _solver_.

Here is the call graph for this function:

◆ O3ClassFactory() [3/3]

template<GUM_Numeric GUM_SCALAR>
gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::O3ClassFactory ( O3ClassFactory< GUM_SCALAR > && src)

Definition at line 77 of file O3ClassFactory_tpl.h.

References O3ClassFactory(), _classMap_, _dag_, _errors_, _nameMap_, _nodeMap_, _o3_prm_, _o3Classes_, _prm_, and _solver_.

Here is the call graph for this function:

◆ ~O3ClassFactory()

template<GUM_Numeric GUM_SCALAR>
gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::~O3ClassFactory ( )

Definition at line 87 of file O3ClassFactory_tpl.h.

References O3ClassFactory().

Here is the call graph for this function:

Member Function Documentation

◆ _addParameters_()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_addParameters_ ( PRMFactory< GUM_SCALAR > & factory,
O3Class & c )
private

Definition at line 329 of file O3ClassFactory_tpl.h.

330 {
331 for (auto& p: c.parameters()) {
332 switch (p.type()) {
334 factory.addParameter("int", p.name().label(), p.value().value());
335 break;
336 }
337
339 factory.addParameter("real", p.name().label(), p.value().value());
340 break;
341 }
342
343 default : {
344 GUM_ERROR(FatalError, "unknown O3Parameter type")
345 }
346 }
347 }
348 }

References gum::prm::PRMFactory< GUM_SCALAR >::addParameter(), gum::prm::o3prm::O3Parameter::FLOAT, GUM_ERROR, gum::prm::o3prm::O3Parameter::INT, and gum::prm::o3prm::O3Class::parameters().

Referenced by _checkImplementation_(), and buildParameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _addParamsToForms_()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_addParamsToForms_ ( const HashTable< std::string, const PRMParameter< GUM_SCALAR > * > & scope,
O3RuleCPT::O3Rule & rule )
private

Definition at line 707 of file O3ClassFactory_tpl.h.

709 {
710 // Add parameters to formulas
711 for (auto& f: rule.second) {
712 f.formula().variables().clear();
713 for (const auto& values: scope) {
714 f.formula().variables().insert(values.first, values.second->value());
715 }
716 }
717 }

Referenced by _checkImplementation_(), and _checkRuleCPT_().

Here is the caller graph for this function:

◆ _addReferenceSlots_()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_addReferenceSlots_ ( O3Class & c)
private

Definition at line 360 of file O3ClassFactory_tpl.h.

360 {
362
363 factory.continueClass(c.name().label());
364
365 // References
366 for (auto& ref: c.referenceSlots()) {
367 if (_checkReferenceSlot_(c, ref)) {
368 factory.addReferenceSlot(ref.type().label(), ref.name().label(), ref.isArray());
369 }
370 }
371
372 factory.endClass(false);
373 }
bool _checkReferenceSlot_(O3Class &c, O3ReferenceSlot &ref)

References _checkReferenceSlot_(), _prm_, gum::prm::PRMFactory< GUM_SCALAR >::addReferenceSlot(), gum::prm::PRMFactory< GUM_SCALAR >::continueClass(), gum::prm::PRMFactory< GUM_SCALAR >::endClass(), gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Class::name(), and gum::prm::o3prm::O3Class::referenceSlots().

Referenced by _checkImplementation_(), and buildReferenceSlots().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkAggParameters_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkAggParameters_ ( O3Class & o3class,
O3Aggregate & agg,
const PRMType * t )
private

Definition at line 971 of file O3ClassFactory_tpl.h.

973 {
974 bool ok = false;
975
976 switch (gum::prm::PRMAggregate< GUM_SCALAR >::str2enum(agg.aggregateType().label())) {
985 break;
986 }
987
992 break;
993 }
994
995 default : {
996 GUM_ERROR(FatalError, "unknown aggregate type")
997 }
998 }
999
1000 if (!ok) { return false; }
1001
1002 // Checking parameters type
1003 switch (gum::prm::PRMAggregate< GUM_SCALAR >::str2enum(agg.aggregateType().label())) {
1008 break;
1009 }
1010
1011 default : { /* Nothing to do */
1012 }
1013 }
1014
1015 return ok;
1016 }
bool _checkParameterValue_(O3Aggregate &agg, const gum::prm::PRMType &t)
bool _checkParametersNumber_(O3Aggregate &agg, Size n)

References _checkParametersNumber_(), _checkParameterValue_(), gum::prm::o3prm::O3Aggregate::aggregateType(), gum::prm::PRMAggregate< GUM_SCALAR >::AMPLITUDE, gum::prm::PRMAggregate< GUM_SCALAR >::AND, gum::prm::PRMAggregate< GUM_SCALAR >::COUNT, gum::prm::PRMAggregate< GUM_SCALAR >::EXISTS, gum::prm::PRMAggregate< GUM_SCALAR >::FORALL, GUM_ERROR, gum::prm::o3prm::O3Label::label(), gum::prm::PRMAggregate< GUM_SCALAR >::MAX, gum::prm::PRMAggregate< GUM_SCALAR >::MEDIAN, gum::prm::PRMAggregate< GUM_SCALAR >::MIN, gum::prm::PRMAggregate< GUM_SCALAR >::OR, gum::prm::PRMAggregate< GUM_SCALAR >::str2enum(), and gum::prm::PRMAggregate< GUM_SCALAR >::SUM.

Referenced by _checkAggregateForCompletion_(), and _checkImplementation_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkAggParents_()

template<GUM_Numeric GUM_SCALAR>
const PRMType * gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkAggParents_ ( O3Class & o3class,
O3Aggregate & agg )
private

Definition at line 921 of file O3ClassFactory_tpl.h.

922 {
923 const auto& c = _prm_->getClass(o3class.name().label());
924 auto t = (const PRMType*)nullptr;
925
926 for (const auto& prnt: agg.parents()) {
927 auto elt = _resolveSlotChain_(c, prnt);
928
929 if (elt == nullptr) {
931 return nullptr;
932
933 } else {
934 if (t == nullptr) {
935 try {
936 t = &(elt->type());
937
938 } catch (OperationNotAllowed const&) {
940 return nullptr;
941 }
942
943 } else if ((*t) != elt->type()) {
944 // Wront type in chain
945 O3PRM_CLASS_WRONG_PARENT_TYPE(prnt, t->name(), elt->type().name(), *_errors_);
946 return nullptr;
947 }
948 }
949 }
950 return t;
951 }
const PRMClassElement< GUM_SCALAR > * _resolveSlotChain_(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain)

References _errors_, _prm_, _resolveSlotChain_(), gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Class::name(), and gum::prm::o3prm::O3Aggregate::parents().

Referenced by _checkAggregateForCompletion_(), and _checkImplementation_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkAggregateForCompletion_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkAggregateForCompletion_ ( O3Class & o3class,
O3Aggregate & agg )
private

Definition at line 562 of file O3ClassFactory_tpl.h.

563 {
564 // Checking parents
565 auto t = _checkAggParents_(c, agg);
566 if (t == nullptr) { return false; }
567
568 // Checking parameters numbers
569 if (!_checkAggParameters_(c, agg, t)) { return false; }
570
571 return true;
572 }
bool _checkAggParameters_(O3Class &o3class, O3Aggregate &agg, const PRMType *t)
const PRMType * _checkAggParents_(O3Class &o3class, O3Aggregate &agg)

References _checkAggParameters_(), and _checkAggParents_().

Referenced by _checkImplementation_(), and _completeAggregates_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkAggregateForDeclaration_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkAggregateForDeclaration_ ( O3Class & o3class,
O3Aggregate & agg )
private

Definition at line 910 of file O3ClassFactory_tpl.h.

911 {
912 if (!_solver_->resolveType(agg.variableType())) { return false; }
913
914 // Checking type legality if overload
915 if (!_checkAggTypeLegality_(o3class, agg)) { return false; }
916
917 return true;
918 }
bool _checkAggTypeLegality_(O3Class &o3class, O3Aggregate &agg)

References _checkAggTypeLegality_(), _solver_, and gum::prm::o3prm::O3Aggregate::variableType().

Referenced by _checkImplementation_(), and _declareAggregates_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkAggTypeLegality_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkAggTypeLegality_ ( O3Class & o3class,
O3Aggregate & agg )
private

Definition at line 954 of file O3ClassFactory_tpl.h.

955 {
956 if (_prm_->isClass(o3class.superLabel().label())) {
957 const auto& super = _prm_->getClass(o3class.superLabel().label());
958 const auto& agg_type = _prm_->type(agg.variableType().label());
959
960 if (super.exists(agg.name().label())
961 && !agg_type.isSubTypeOf(super.get(agg.name().label()).type())) {
962 O3PRM_CLASS_ILLEGAL_OVERLOAD(agg.name(), o3class.superLabel(), *_errors_);
963 return false;
964 }
965 }
966
967 return true;
968 }

References _errors_, _prm_, gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Aggregate::name(), gum::prm::o3prm::O3Class::superLabel(), and gum::prm::o3prm::O3Aggregate::variableType().

Referenced by _checkAggregateForDeclaration_(), and _checkImplementation_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkAndAddArcsToDag_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkAndAddArcsToDag_ ( )
private

Definition at line 181 of file O3ClassFactory_tpl.h.

181 {
182 for (auto& c: _o3_prm_->classes()) {
183 if (c->superLabel().label() != "") {
184 if (!_solver_->resolveClass(c->superLabel())) { return false; }
185
186 auto head = _nameMap_[c->superLabel().label()];
187 auto tail = _nameMap_[c->name().label()];
188
189 try {
190 _dag_.addArc(tail, head);
191 } catch (InvalidDirectedCycle const&) {
192 // Cyclic inheritance
193 O3PRM_CLASS_CYLIC_INHERITANCE(c->name(), c->superLabel(), *_errors_);
194 return false;
195 }
196 }
197 }
198
199 return true;
200 }

References _dag_, _errors_, _nameMap_, _o3_prm_, and _solver_.

Referenced by _checkO3Classes_().

Here is the caller graph for this function:

◆ _checkAndAddNodesToDag_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkAndAddNodesToDag_ ( )
private

Definition at line 162 of file O3ClassFactory_tpl.h.

162 {
163 for (auto& c: _o3_prm_->classes()) {
164 auto id = _dag_.addNode();
165
166 try {
167 _nameMap_.insert(c->name().label(), id);
168 _classMap_.insert(c->name().label(), c.get());
169 _nodeMap_.insert(id, c.get());
170
171 } catch (DuplicateElement const&) {
173 return false;
174 }
175 }
176
177 return true;
178 }

References _classMap_, _dag_, _errors_, _nameMap_, _nodeMap_, and _o3_prm_.

Referenced by _checkO3Classes_().

Here is the caller graph for this function:

◆ _checkAttributeForCompletion_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkAttributeForCompletion_ ( const O3Class & o3_c,
O3Attribute & attr )
private

Definition at line 617 of file O3ClassFactory_tpl.h.

618 {
619 // Check for parents existence
620 const auto& c = _prm_->getClass(o3_c.name().label());
621 for (auto& prnt: attr.parents()) {
622 if (!_checkParent_(c, prnt)) { return false; }
623 }
624
625 // Check that CPT sums to 1
626 if (auto raw = dynamic_cast< O3RawCPT* >(&attr)) { return _checkRawCPT_(c, *raw); }
627
628 if (auto rule = dynamic_cast< O3RuleCPT* >(&attr)) { return _checkRuleCPT_(c, *rule); }
629
630 return true;
631 }
bool _checkParent_(const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
bool _checkRuleCPT_(const PRMClass< GUM_SCALAR > &c, O3RuleCPT &attr)
bool _checkRawCPT_(const PRMClass< GUM_SCALAR > &c, O3RawCPT &attr)

References _checkParent_(), _checkRawCPT_(), _checkRuleCPT_(), _prm_, gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Class::name(), and gum::prm::o3prm::O3Attribute::parents().

Referenced by _checkImplementation_(), and _completeAttribute_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkAttributeForDeclaration_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkAttributeForDeclaration_ ( O3Class & o3_c,
O3Attribute & attr )
private

Definition at line 466 of file O3ClassFactory_tpl.h.

467 {
468 // Check type
469 if (!_solver_->resolveType(attr.type())) { return false; }
470
471 // Checking type legality if overload
472 if (c.superLabel().label() != "") {
473 const auto& super = _prm_->getClass(c.superLabel().label());
474
475 if (!super.exists(attr.name().label())) { return true; }
476
477 const auto& super_type = super.get(attr.name().label()).type();
478 const auto& type = _prm_->type(attr.type().label());
479
480 if (!type.isSubTypeOf(super_type)) {
481 O3PRM_CLASS_ILLEGAL_OVERLOAD(attr.name(), c.superLabel(), *_errors_);
482 return false;
483 }
484 }
485 return true;
486 }

References _errors_, _prm_, _solver_, gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Attribute::name(), gum::prm::o3prm::O3Class::superLabel(), and gum::prm::o3prm::O3Attribute::type().

Referenced by _checkImplementation_(), and _declareAttribute_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkImplementation_() [1/4]

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkImplementation_ ( O3Class & c)
private

Definition at line 216 of file O3ClassFactory_tpl.h.

216 {
217 // Saving attributes names for fast lookup
218 auto attr_map = AttrMap();
219 for (auto& a: c.attributes()) {
220 attr_map.insert(a->name().label(), a.get());
221 }
222
223 // Saving aggregates names for fast lookup
224 auto agg_map = AggMap();
225 for (auto& agg: c.aggregates()) {
226 agg_map.insert(agg.name().label(), &agg);
227 }
228
229 auto ref_map = RefMap();
230 for (auto& ref: c.referenceSlots()) {
231 ref_map.insert(ref.name().label(), &ref);
232 }
233
234 // Cheking interface implementation
235 for (auto& i: c.interfaces()) {
236 if (_solver_->resolveInterface(i)) {
237 if (!_checkImplementation_(c, i, attr_map, agg_map, ref_map)) { return false; }
238 }
239 }
240
241 return true;
242 }

References _checkImplementation_(), _solver_, gum::prm::o3prm::O3Class::aggregates(), gum::prm::o3prm::O3Class::attributes(), gum::prm::o3prm::O3Class::interfaces(), and gum::prm::o3prm::O3Class::referenceSlots().

Referenced by _checkImplementation_(), _checkImplementation_(), and buildImplementations().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkImplementation_() [2/4]

◆ _checkImplementation_() [3/4]

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkImplementation_ ( O3Label & o3_type,
const PRMClassElementContainer< GUM_SCALAR > & type )
private

Definition at line 301 of file O3ClassFactory_tpl.h.

303 {
304 if (!_solver_->resolveSlotType(o3_type)) { return false; }
305
306 if (_prm_->isInterface(o3_type.label())) {
307 return _prm_->getInterface(o3_type.label()).isSubTypeOf(type);
308 } else {
309 return _prm_->getClass(o3_type.label()).isSubTypeOf(type);
310 }
311 }

References _prm_, _solver_, and gum::prm::o3prm::O3Label::label().

Here is the call graph for this function:

◆ _checkImplementation_() [4/4]

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkImplementation_ ( O3Label & o3_type,
const PRMType & type )
private

Definition at line 293 of file O3ClassFactory_tpl.h.

294 {
295 if (!_solver_->resolveType(o3_type)) { return false; }
296
297 return _prm_->type(o3_type.label()).isSubTypeOf(type);
298 }

References _prm_, _solver_, and gum::prm::o3prm::O3Label::label().

Here is the call graph for this function:

◆ _checkLabelsNumber_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkLabelsNumber_ ( const O3RuleCPT & attr,
const O3RuleCPT::O3Rule & rule )
private

Definition at line 672 of file O3ClassFactory_tpl.h.

673 {
674 // Check that the number of labels is correct
675 if (rule.first.size() != attr.parents().size()) {
676 O3PRM_CLASS_ILLEGAL_RULE_SIZE(rule, rule.first.size(), attr.parents().size(), *_errors_);
677 return false;
678 }
679 return true;
680 }

References _errors_, and gum::prm::o3prm::O3Attribute::parents().

Referenced by _checkImplementation_(), and _checkRuleCPT_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkLabelsValues_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkLabelsValues_ ( const PRMClass< GUM_SCALAR > & c,
const O3RuleCPT & attr,
const O3RuleCPT::O3Rule & rule )
private

Definition at line 683 of file O3ClassFactory_tpl.h.

685 {
686 bool errors = false;
687 for (std::size_t i = 0; i < attr.parents().size(); ++i) {
688 auto label = rule.first[i];
689 auto prnt = attr.parents()[i];
690 try {
691 auto real_labels = _resolveSlotChain_(c, prnt)->type()->labels();
692 // c.get(prnt.label()).type()->labels();
693 if (label.label() != "*"
694 && std::find(real_labels.begin(), real_labels.end(), label.label())
695 == real_labels.end()) {
697 errors = true;
698 }
699 } catch (Exception const&) {
700 // parent does not exists and is already reported
701 }
702 }
703 return errors == false;
704 }

References _errors_, _resolveSlotChain_(), and gum::prm::o3prm::O3Attribute::parents().

Referenced by _checkImplementation_(), and _checkRuleCPT_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkLocalParent_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkLocalParent_ ( const PRMClass< GUM_SCALAR > & c,
const O3Label & prnt )
private

Definition at line 645 of file O3ClassFactory_tpl.h.

646 {
647 if (!c.exists(prnt.label())) {
649 return false;
650 }
651
652 const auto& elt = c.get(prnt.label());
657 return false;
658 }
659
660 return true;
661 }

References _errors_, gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClass< GUM_SCALAR >::get(), gum::prm::PRMClassElement< GUM_SCALAR >::isAggregate(), gum::prm::PRMClassElement< GUM_SCALAR >::isAttribute(), gum::prm::PRMClassElement< GUM_SCALAR >::isSlotChain(), and gum::prm::o3prm::O3Label::label().

Referenced by _checkImplementation_(), and _checkParent_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkO3Classes_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkO3Classes_ ( )
private

Definition at line 157 of file O3ClassFactory_tpl.h.

References _checkAndAddArcsToDag_(), and _checkAndAddNodesToDag_().

Referenced by buildClasses().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkParametersNumber_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkParametersNumber_ ( O3Aggregate & agg,
Size n )
private

Definition at line 1019 of file O3ClassFactory_tpl.h.

1019 {
1020 if (agg.parameters().size() != n) {
1021 O3PRM_CLASS_AGG_PARAMETERS(agg.name(), Size(n), Size(agg.parameters().size()), *_errors_);
1022 return false;
1023 }
1024
1025 return true;
1026 }

References _errors_, gum::prm::o3prm::O3Aggregate::name(), and gum::prm::o3prm::O3Aggregate::parameters().

Referenced by _checkAggParameters_(), and _checkImplementation_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkParameterValue_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkParameterValue_ ( O3Aggregate & agg,
const gum::prm::PRMType & t )
private

Definition at line 1029 of file O3ClassFactory_tpl.h.

1030 {
1031 const auto& param = agg.parameters().front();
1032 bool found = false;
1033 for (Size idx = 0; idx < t.variable().domainSize(); ++idx) {
1034 if (t.variable().label(idx) == param.label()) {
1035 found = true;
1036 break;
1037 }
1038 }
1039
1040 if (!found) {
1042 return false;
1043 }
1044
1045 return true;
1046 }

References _errors_, gum::DiscreteVariable::label(), gum::prm::o3prm::O3Aggregate::name(), gum::prm::o3prm::O3Aggregate::parameters(), and gum::prm::PRMType::variable().

Referenced by _checkAggParameters_(), and _checkImplementation_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkParent_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkParent_ ( const PRMClass< GUM_SCALAR > & c,
const O3Label & prnt )
private

Definition at line 634 of file O3ClassFactory_tpl.h.

635 {
636 if (prnt.label().find('.') == std::string::npos) {
637 return _checkLocalParent_(c, prnt);
638
639 } else {
640 return _checkRemoteParent_(c, prnt);
641 }
642 }
bool _checkLocalParent_(const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
bool _checkRemoteParent_(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &prnt)

References _checkLocalParent_(), _checkRemoteParent_(), and gum::prm::o3prm::O3Label::label().

Referenced by _checkAttributeForCompletion_(), and _checkImplementation_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkRawCPT_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkRawCPT_ ( const PRMClass< GUM_SCALAR > & c,
O3RawCPT & attr )
private

Definition at line 771 of file O3ClassFactory_tpl.h.

772 {
773 const auto& type = _prm_->type(attr.type().label());
774
775 auto domainSize = type->domainSize();
776 for (auto& prnt: attr.parents()) {
777 if (c.exists(prnt.label())) {
778 domainSize *= c.get(prnt.label()).type()->domainSize();
779 } else {
780 // If we are here, all parents have been check so _resolveSlotChain_
781 // will not raise an error and not return a nullptr
782 domainSize *= _resolveSlotChain_(c, prnt)->type()->domainSize();
783 }
784 }
785
786 // Check for CPT size
787 if (domainSize != attr.values().size()) {
789 attr.name(),
790 Size(attr.values().size()),
792 *_errors_);
793 return false;
794 }
795
796 // Add parameters to formulas
797 const auto& scope = c.scope();
798 for (auto& f: attr.values()) {
799 f.formula().variables().clear();
800
801 for (const auto& values: scope) {
802 f.formula().variables().insert(values.first, values.second->value());
803 }
804 }
805
806 // Check that CPT sums to 1
807 Size parent_size = domainSize / type->domainSize();
809
810 for (std::size_t i = 0; i < attr.values().size(); ++i) {
811 try {
812 auto idx = i % parent_size;
813 auto val = (GUM_SCALAR)attr.values()[i].formula().result();
814 values[idx] += val;
815
816 if (val < 0.0 || 1.0 < val) {
817 O3PRM_CLASS_ILLEGAL_CPT_VALUE(c.name(), attr.name(), attr.values()[i], *_errors_);
818 return false;
819 }
820 } catch (Exception const&) {
821 O3PRM_CLASS_ILLEGAL_CPT_VALUE(c.name(), attr.name(), attr.values()[i], *_errors_);
822 return false;
823 }
824 }
825
826 for (auto f: values) {
827 if (std::abs(f - GUM_SCALAR(1.0)) > config().epsilonCoarse()) {
828 O3PRM_CLASS_CPT_DOES_NOT_SUM_TO_1(c.name(), attr.name(), float(f), *_errors_);
829 return false;
830 } else if (std::abs(f - GUM_SCALAR(1.0)) > config().epsilonStandard()) {
832 }
833 }
834 return true;
835 }

References _errors_, _prm_, _resolveSlotChain_(), gum::config(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::PRMClass< GUM_SCALAR >::get(), gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Attribute::name(), gum::prm::PRMObject::name(), gum::prm::o3prm::O3Attribute::parents(), gum::prm::PRMClass< GUM_SCALAR >::scope(), gum::prm::o3prm::O3Attribute::type(), and gum::prm::o3prm::O3RawCPT::values().

Referenced by _checkAttributeForCompletion_(), and _checkImplementation_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkReferenceSlot_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkReferenceSlot_ ( O3Class & c,
O3ReferenceSlot & ref )
private

Definition at line 376 of file O3ClassFactory_tpl.h.

376 {
377 if (!_solver_->resolveSlotType(ref.type())) { return false; }
378
379 const auto& real_c = _prm_->getClass(c.name().label());
380
381 // Check for dupplicates
382 if (real_c.exists(ref.name().label())) {
383 const auto& elt = real_c.get(ref.name().label());
384
387
388 if (_prm_->isInterface(ref.type().label())) {
389 slot_type = &(_prm_->getInterface(ref.type().label()));
390
391 } else {
392 slot_type = &(_prm_->getClass(ref.type().label()));
393 }
394
395 auto real_ref = static_cast< const PRMReferenceSlot< GUM_SCALAR >* >(&elt);
396
397 if (slot_type->name() == real_ref->slotType().name()) {
399 return false;
400
401 } else if (!slot_type->isSubTypeOf(real_ref->slotType())) {
402 O3PRM_CLASS_ILLEGAL_OVERLOAD(ref.name(), c.name(), *_errors_);
403 return false;
404 }
405
406 } else {
408 return false;
409 }
410 }
411
412 // If class we need to check for illegal references
413 if (_prm_->isClass(ref.type().label())) {
414 const auto& ref_type = _prm_->getClass(ref.type().label());
415
416 // No recursive reference
417 if ((&ref_type) == (&real_c)) {
418 O3PRM_CLASS_SELF_REFERENCE(c.name(), ref.name(), *_errors_);
419 return false;
420 }
421
422 // No reference to subclasses
423 if (ref_type.isSubTypeOf(real_c)) {
425 return false;
426 }
427 }
428
429 return true;
430 }

References _errors_, _prm_, _solver_, gum::prm::PRMClassElement< GUM_SCALAR >::isReferenceSlot(), gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Class::name(), gum::prm::o3prm::O3ReferenceSlot::name(), and gum::prm::o3prm::O3ReferenceSlot::type().

Referenced by _addReferenceSlots_(), and _checkImplementation_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkRemoteParent_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkRemoteParent_ ( const PRMClassElementContainer< GUM_SCALAR > & c,
const O3Label & prnt )
private

Definition at line 664 of file O3ClassFactory_tpl.h.

666 {
667 if (_resolveSlotChain_(c, prnt) == nullptr) { return false; }
668 return true;
669 }

References _resolveSlotChain_().

Referenced by _checkImplementation_(), and _checkParent_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkRuleCPT_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkRuleCPT_ ( const PRMClass< GUM_SCALAR > & c,
O3RuleCPT & attr )
private

Definition at line 751 of file O3ClassFactory_tpl.h.

752 {
753 const auto& scope = c.scope();
754 bool errors = false;
755 for (auto& rule: attr.rules()) {
756 try {
757 if (!_checkLabelsNumber_(attr, rule)) { errors = true; }
758 if (!_checkLabelsValues_(c, attr, rule)) { errors = true; }
760 if (!_checkRuleCPTSumsTo1_(c, attr, rule)) { errors = true; }
761 } catch (Exception& e) {
763 errors = true;
764 }
765 }
766
767 return errors == false;
768 }
bool _checkLabelsValues_(const PRMClass< GUM_SCALAR > &c, const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
void _addParamsToForms_(const HashTable< std::string, const PRMParameter< GUM_SCALAR > * > &scope, O3RuleCPT::O3Rule &rule)
bool _checkLabelsNumber_(const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
bool _checkRuleCPTSumsTo1_(const PRMClass< GUM_SCALAR > &c, const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)

References _addParamsToForms_(), _checkLabelsNumber_(), _checkLabelsValues_(), _checkRuleCPTSumsTo1_(), GUM_SHOWERROR, gum::prm::o3prm::O3RuleCPT::rules(), and gum::prm::PRMClass< GUM_SCALAR >::scope().

Referenced by _checkAttributeForCompletion_(), and _checkImplementation_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkRuleCPTSumsTo1_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkRuleCPTSumsTo1_ ( const PRMClass< GUM_SCALAR > & c,
const O3RuleCPT & attr,
const O3RuleCPT::O3Rule & rule )
private

Definition at line 720 of file O3ClassFactory_tpl.h.

722 {
723 bool errors = false;
724 // Check that formulas are valid and sums to 1
725 GUM_SCALAR sum = 0.0;
726 for (const auto& f: rule.second) {
727 try {
728 auto value = GUM_SCALAR(f.formula().result());
729 sum += value;
730 if (value < 0.0 || 1.0 < value) {
731 O3PRM_CLASS_ILLEGAL_CPT_VALUE(c.name(), attr.name(), f, *_errors_);
732 errors = true;
733 }
734 } catch (OperationNotAllowed const&) {
735 O3PRM_CLASS_ILLEGAL_CPT_VALUE(c.name(), attr.name(), f, *_errors_);
736 errors = true;
737 }
738 }
739
740 // Check that CPT sums to 1
741 if (std::abs(sum - 1.0) > config().epsilonCoarse()) {
742 O3PRM_CLASS_CPT_DOES_NOT_SUM_TO_1(c.name(), attr.name(), float(sum), *_errors_);
743 errors = true;
744 } else if (std::abs(sum - 1.0f) > config().epsilonStandard()) {
746 }
747 return errors == false;
748 }

References _errors_, gum::config(), gum::prm::o3prm::O3Attribute::name(), and gum::prm::PRMObject::name().

Referenced by _checkImplementation_(), and _checkRuleCPT_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _checkSlotChainLink_()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkSlotChainLink_ ( const PRMClassElementContainer< GUM_SCALAR > & c,
const O3Label & chain,
std::string_view s )
private

Definition at line 875 of file O3ClassFactory_tpl.h.

878 {
879 if (!c.exists(s)) {
881 return false;
882 }
883 return true;
884 }

References _errors_, and gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists().

Referenced by _checkImplementation_(), and _resolveSlotChain_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _completeAggregates_()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAggregates_ ( PRMFactory< GUM_SCALAR > & factory,
O3Class & c )
private

Definition at line 545 of file O3ClassFactory_tpl.h.

546 {
547 // Attributes
548 for (auto& agg: c.aggregates()) {
550 factory.continueAggregator(agg.name().label());
551
552 for (const auto& parent: agg.parents()) {
553 factory.addParent(parent.label());
554 }
555
556 factory.endAggregator();
557 }
558 }
559 }
bool _checkAggregateForCompletion_(O3Class &o3class, O3Aggregate &agg)

References _checkAggregateForCompletion_(), gum::prm::PRMFactory< GUM_SCALAR >::addParent(), gum::prm::o3prm::O3Class::aggregates(), gum::prm::PRMFactory< GUM_SCALAR >::continueAggregator(), and gum::prm::PRMFactory< GUM_SCALAR >::endAggregator().

Referenced by _checkImplementation_(), and completeAggregates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _completeAttribute_()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_completeAttribute_ ( PRMFactory< GUM_SCALAR > & factory,
O3Class & c )
private

Definition at line 575 of file O3ClassFactory_tpl.h.

576 {
577 // Attributes
578 for (auto& attr: c.attributes()) {
580 factory.continueAttribute(attr->name().label());
581
582 for (const auto& parent: attr->parents()) {
583 factory.addParent(parent.label());
584 }
585
586 if (auto raw = dynamic_cast< const O3RawCPT* >(attr.get())) {
588 for (const auto& val: raw->values()) {
589 values.push_back(val.formula().formula());
590 }
591 factory.setRawCPFByColumns(values);
592 }
593
594 if (auto rule_cpt = dynamic_cast< const O3RuleCPT* >(attr.get())) {
595 for (const auto& rule: rule_cpt->rules()) {
598
599 for (const auto& lbl: rule.first) {
600 labels.push_back(lbl.label());
601 }
602
603 for (const auto& form: rule.second) {
604 values.push_back(form.formula().formula());
605 }
606
607 factory.setCPFByRule(labels, values);
608 }
609 }
610
611 factory.endAttribute();
612 }
613 }
614 }
bool _checkAttributeForCompletion_(const O3Class &o3_c, O3Attribute &attr)

References _checkAttributeForCompletion_(), gum::prm::PRMFactory< GUM_SCALAR >::addParent(), gum::prm::o3prm::O3Class::attributes(), gum::prm::PRMFactory< GUM_SCALAR >::continueAttribute(), gum::prm::PRMFactory< GUM_SCALAR >::endAttribute(), gum::prm::PRMFactory< GUM_SCALAR >::setCPFByRule(), and gum::prm::PRMFactory< GUM_SCALAR >::setRawCPFByColumns().

Referenced by _checkImplementation_(), and completeAttributes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _declareAggregates_()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAggregates_ ( O3Class & c)
private

Definition at line 887 of file O3ClassFactory_tpl.h.

887 {
889 factory.continueClass(c.name().label());
890
891 for (auto& agg: c.aggregates()) {
894 for (auto& p: agg.parameters()) {
895 params.push_back(p.label());
896 }
897
898 factory.startAggregator(agg.name().label(),
899 agg.aggregateType().label(),
900 agg.variableType().label(),
901 params);
902 factory.endAggregator();
903 }
904 }
905
906 factory.endClass(false);
907 }
bool _checkAggregateForDeclaration_(O3Class &o3class, O3Aggregate &agg)

References _checkAggregateForDeclaration_(), _prm_, gum::prm::o3prm::O3Class::aggregates(), gum::prm::PRMFactory< GUM_SCALAR >::continueClass(), gum::prm::PRMFactory< GUM_SCALAR >::endAggregator(), gum::prm::PRMFactory< GUM_SCALAR >::endClass(), gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Class::name(), and gum::prm::PRMFactory< GUM_SCALAR >::startAggregator().

Referenced by _checkImplementation_(), and declareAggregates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _declareAttribute_()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_declareAttribute_ ( O3Class & c)
private

Definition at line 451 of file O3ClassFactory_tpl.h.

451 {
453 factory.continueClass(c.name().label());
454
455 for (auto& attr: c.attributes()) {
457 factory.startAttribute(attr->type().label(), attr->name().label());
458 factory.endAttribute();
459 }
460 }
461
462 factory.endClass(false);
463 }
bool _checkAttributeForDeclaration_(O3Class &o3_c, O3Attribute &attr)

References _checkAttributeForDeclaration_(), _prm_, gum::prm::o3prm::O3Class::attributes(), gum::prm::PRMFactory< GUM_SCALAR >::continueClass(), gum::prm::PRMFactory< GUM_SCALAR >::endAttribute(), gum::prm::PRMFactory< GUM_SCALAR >::endClass(), gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Class::name(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

Referenced by _checkImplementation_(), and declareAttributes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _resolveSlotChain_()

template<GUM_Numeric GUM_SCALAR>
const PRMClassElement< GUM_SCALAR > * gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_resolveSlotChain_ ( const PRMClassElementContainer< GUM_SCALAR > & c,
const O3Label & chain )
private

Definition at line 838 of file O3ClassFactory_tpl.h.

840 {
841 auto s = chain.label();
842 auto current = &c;
844
845 decomposePath(chain.label(), v);
846
847 for (size_t i = 0; i < v.size(); ++i) {
848 auto link = v[i];
849
850 if (!_checkSlotChainLink_(*current, chain, link)) { return nullptr; }
851
852 auto elt = &(current->get(link));
853
854 if (i == v.size() - 1) {
855 // last link, should be an attribute or aggregate
856 return elt;
857
858 } else {
859 // should be a reference slot
860
861 if (auto ref = dynamic_cast< const PRMReferenceSlot< GUM_SCALAR >* >(elt)) {
862 current = &(ref->slotType());
863 } else {
864 return nullptr; // failsafe to prevent infinite loop
865 }
866 }
867 }
868
869 // Encountered only reference slots
870
871 return nullptr;
872 }
bool _checkSlotChainLink_(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain, std::string_view s)

References _checkSlotChainLink_(), gum::prm::decomposePath(), and gum::prm::o3prm::O3Label::label().

Referenced by _checkAggParents_(), _checkImplementation_(), _checkLabelsValues_(), _checkRawCPT_(), and _checkRemoteParent_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _setO3ClassCreationOrder_()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_setO3ClassCreationOrder_ ( )
private

Definition at line 148 of file O3ClassFactory_tpl.h.

148 {
149 auto topo_order = _dag_.topologicalOrder();
150
151 for (auto id = topo_order.rbegin(); id != topo_order.rend(); --id) {
152 _o3Classes_.push_back(_nodeMap_[*id]);
153 }
154 }

References _dag_, _nodeMap_, and _o3Classes_.

Referenced by buildClasses().

Here is the caller graph for this function:

◆ buildClasses()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::buildClasses ( )

Definition at line 124 of file O3ClassFactory_tpl.h.

124 {
126
127 // Class with a super class must be declared after
128 if (_checkO3Classes_()) {
130
131 for (auto c: _o3Classes_) {
132 // Soving interfaces
134 for (auto& i: c->interfaces()) {
135 if (_solver_->resolveInterface(i)) { implements.insert(i.label()); }
136 }
137
138 // Adding the class
139 if (_solver_->resolveClass(c->superLabel())) {
140 factory.startClass(c->name().label(), c->superLabel().label(), &implements, true);
141 factory.endClass(false);
142 }
143 }
144 }
145 }

References _checkO3Classes_(), _o3Classes_, _prm_, _setO3ClassCreationOrder_(), _solver_, gum::prm::PRMFactory< GUM_SCALAR >::endClass(), and gum::prm::PRMFactory< GUM_SCALAR >::startClass().

Here is the call graph for this function:

◆ buildImplementations()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::buildImplementations ( )

Definition at line 203 of file O3ClassFactory_tpl.h.

203 {
204 for (auto& c: _o3_prm_->classes()) {
205 if (_checkImplementation_(*c)) {
206 _prm_->getClass(c->name().label()).initializeInheritance();
207 }
208 }
209 }

References _checkImplementation_(), _o3_prm_, and _prm_.

Here is the call graph for this function:

◆ buildParameters()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::buildParameters ( )

Definition at line 314 of file O3ClassFactory_tpl.h.

314 {
316 // Class with a super class must be declared after
317 for (auto c: _o3Classes_) {
318 _prm_->getClass(c->name().label()).inheritParameters();
319
320 factory.continueClass(c->name().label());
321
323
324 factory.endClass(false);
325 }
326 }
void _addParameters_(PRMFactory< GUM_SCALAR > &factory, O3Class &c)

References _addParameters_(), _o3Classes_, _prm_, gum::prm::PRMFactory< GUM_SCALAR >::continueClass(), gum::prm::PRMFactory< GUM_SCALAR >::endClass(), gum::prm::o3prm::O3Label::label(), and gum::prm::o3prm::O3Class::name().

Here is the call graph for this function:

◆ buildReferenceSlots()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::buildReferenceSlots ( )

Definition at line 351 of file O3ClassFactory_tpl.h.

351 {
352 // Class with a super class must be declared after
353 for (auto c: _o3Classes_) {
354 _prm_->getClass(c->name().label()).inheritReferenceSlots();
356 }
357 }

References _addReferenceSlots_(), _o3Classes_, _prm_, gum::prm::o3prm::O3Label::label(), and gum::prm::o3prm::O3Class::name().

Here is the call graph for this function:

◆ completeAggregates()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::completeAggregates ( )

Definition at line 531 of file O3ClassFactory_tpl.h.

531 {
533
534 // Class with a super class must be declared in order
535 for (auto c: _o3Classes_) {
536 factory.continueClass(c->name().label());
537
539
540 factory.endClass(false);
541 }
542 }
void _completeAggregates_(PRMFactory< GUM_SCALAR > &factory, O3Class &c)

References _completeAggregates_(), _o3Classes_, _prm_, gum::prm::PRMFactory< GUM_SCALAR >::continueClass(), gum::prm::PRMFactory< GUM_SCALAR >::endClass(), gum::prm::o3prm::O3Label::label(), and gum::prm::o3prm::O3Class::name().

Here is the call graph for this function:

◆ completeAttributes()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::completeAttributes ( )

Definition at line 489 of file O3ClassFactory_tpl.h.

489 {
491
492 // Class with a super class must be declared in order
493 for (auto c: _o3Classes_) {
494 _prm_->getClass(c->name().label()).inheritSlotChains();
495 factory.continueClass(c->name().label());
496
498
499 if (c->superLabel().label() != "") {
500 auto& super = _prm_->getClass(c->superLabel().label());
502
503 for (auto a: super.attributes()) {
504 to_complete.insert(a->safeName());
505 }
506
507 for (auto a: super.aggregates()) {
508 to_complete.insert(a->safeName());
509 }
510
511 for (auto& a: c->attributes()) {
512 to_complete.erase(
513 _prm_->getClass(c->name().label()).get(a->name().label()).safeName());
514 }
515
516 for (auto& a: c->aggregates()) {
517 to_complete.erase(
518 _prm_->getClass(c->name().label()).get(a.name().label()).safeName());
519 }
520
521 for (auto a: to_complete) {
522 _prm_->getClass(c->name().label()).completeInheritance(a);
523 }
524 }
525
526 factory.endClass(true);
527 }
528 }
void _completeAttribute_(PRMFactory< GUM_SCALAR > &factory, O3Class &c)

References _completeAttribute_(), _o3Classes_, _prm_, gum::prm::o3prm::O3Class::aggregates(), gum::prm::o3prm::O3Class::attributes(), gum::prm::PRMFactory< GUM_SCALAR >::continueClass(), gum::prm::PRMFactory< GUM_SCALAR >::endClass(), gum::prm::o3prm::O3Label::label(), gum::prm::o3prm::O3Class::name(), and gum::prm::o3prm::O3Class::superLabel().

Here is the call graph for this function:

◆ declareAggregates()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::declareAggregates ( )

Definition at line 442 of file O3ClassFactory_tpl.h.

442 {
443 // Class with a super class must be declared after
444 for (auto c: _o3Classes_) {
445 _prm_->getClass(c->name().label()).inheritAggregates();
447 }
448 }

References _declareAggregates_(), _o3Classes_, _prm_, gum::prm::o3prm::O3Label::label(), and gum::prm::o3prm::O3Class::name().

Here is the call graph for this function:

◆ declareAttributes()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::declareAttributes ( )

Definition at line 433 of file O3ClassFactory_tpl.h.

433 {
434 // Class with a super class must be declared after
435 for (auto c: _o3Classes_) {
436 _prm_->getClass(c->name().label()).inheritAttributes();
438 }
439 }

References _declareAttribute_(), _o3Classes_, _prm_, gum::prm::o3prm::O3Label::label(), and gum::prm::o3prm::O3Class::name().

Here is the call graph for this function:

◆ operator=() [1/2]

template<GUM_Numeric GUM_SCALAR>
O3ClassFactory< GUM_SCALAR > & gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::operator= ( const O3ClassFactory< GUM_SCALAR > & src)

Definition at line 93 of file O3ClassFactory_tpl.h.

93 {
94 if (this == &src) { return *this; }
95 _prm_ = src._prm_;
102 _dag_ = src._dag_;
104 return *this;
105 }

References O3ClassFactory(), _classMap_, _dag_, _errors_, _nameMap_, _nodeMap_, _o3_prm_, _o3Classes_, _prm_, and _solver_.

Here is the call graph for this function:

◆ operator=() [2/2]

template<GUM_Numeric GUM_SCALAR>
O3ClassFactory< GUM_SCALAR > & gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::operator= ( O3ClassFactory< GUM_SCALAR > && src)

Definition at line 109 of file O3ClassFactory_tpl.h.

109 {
110 if (this == &src) { return *this; }
120 return *this;
121 }

References O3ClassFactory(), _classMap_, _dag_, _errors_, _nameMap_, _nodeMap_, _o3_prm_, _o3Classes_, _prm_, and _solver_.

Here is the call graph for this function:

Member Data Documentation

◆ _classMap_

template<GUM_Numeric GUM_SCALAR>
HashTable< std::string, O3Class* > gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_classMap_
private

◆ _dag_

template<GUM_Numeric GUM_SCALAR>
DAG gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_dag_
private

◆ _errors_

◆ _nameMap_

template<GUM_Numeric GUM_SCALAR>
HashTable< std::string, gum::NodeId > gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_nameMap_
private

◆ _nodeMap_

template<GUM_Numeric GUM_SCALAR>
HashTable< NodeId, O3Class* > gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_nodeMap_
private

◆ _o3_prm_

template<GUM_Numeric GUM_SCALAR>
O3PRM* gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_o3_prm_
private

◆ _o3Classes_

◆ _prm_

◆ _solver_


The documentation for this class was generated from the following files: