aGrUM 3.1.1
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 >:

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 59 of file O3ClassFactory_tpl.h.

62 :
65 }
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(), 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 68 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 76 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 86 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 328 of file O3ClassFactory_tpl.h.

329 {
330 for (auto& p: c.parameters()) {
331 switch (p.type()) {
333 factory.addParameter("int", p.name().label(), p.value().value());
334 break;
335 }
336
338 factory.addParameter("real", p.name().label(), p.value().value());
339 break;
340 }
341
342 default : {
343 GUM_ERROR(FatalError, "unknown O3Parameter type")
344 }
345 }
346 }
347 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

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 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 706 of file O3ClassFactory_tpl.h.

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

Referenced by _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 359 of file O3ClassFactory_tpl.h.

359 {
361
362 factory.continueClass(c.name().label());
363
364 // References
365 for (auto& ref: c.referenceSlots()) {
366 if (_checkReferenceSlot_(c, ref)) {
367 factory.addReferenceSlot(ref.type().label(), ref.name().label(), ref.isArray());
368 }
369 }
370
371 factory.endClass(false);
372 }
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 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 970 of file O3ClassFactory_tpl.h.

972 {
973 bool ok = false;
974
975 switch (gum::prm::PRMAggregate< GUM_SCALAR >::str2enum(agg.aggregateType().label())) {
984 break;
985 }
986
991 break;
992 }
993
994 default : {
995 GUM_ERROR(FatalError, "unknown aggregate type")
996 }
997 }
998
999 if (!ok) { return false; }
1000
1001 // Checking parameters type
1002 switch (gum::prm::PRMAggregate< GUM_SCALAR >::str2enum(agg.aggregateType().label())) {
1007 break;
1008 }
1009
1010 default : { /* Nothing to do */
1011 }
1012 }
1013
1014 return ok;
1015 }
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_().

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 920 of file O3ClassFactory_tpl.h.

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

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 561 of file O3ClassFactory_tpl.h.

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

References _checkAggParameters_(), and _checkAggParents_().

Referenced by _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 909 of file O3ClassFactory_tpl.h.

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

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

Referenced by _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 953 of file O3ClassFactory_tpl.h.

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

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_().

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 180 of file O3ClassFactory_tpl.h.

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

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 161 of file O3ClassFactory_tpl.h.

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

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 616 of file O3ClassFactory_tpl.h.

617 {
618 // Check for parents existence
619 const auto& c = _prm_->getClass(o3_c.name().label());
620 for (auto& prnt: attr.parents()) {
621 if (!_checkParent_(c, prnt)) { return false; }
622 }
623
624 // Check that CPT sums to 1
625 if (auto raw = dynamic_cast< O3RawCPT* >(&attr)) { return _checkRawCPT_(c, *raw); }
626
627 if (auto rule = dynamic_cast< O3RuleCPT* >(&attr)) { return _checkRuleCPT_(c, *rule); }
628
629 return true;
630 }
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 _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 465 of file O3ClassFactory_tpl.h.

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

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 _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 215 of file O3ClassFactory_tpl.h.

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

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_(), and buildImplementations().

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

◆ _checkImplementation_() [2/4]

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkImplementation_ ( O3Class & c,
O3Label & i,
HashTable< std::string, O3Attribute * > & attrMap,
HashTable< std::string, O3Aggregate * > & aggMap,
HashTable< std::string, O3ReferenceSlot * > & refMap )
private

◆ _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 300 of file O3ClassFactory_tpl.h.

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

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 292 of file O3ClassFactory_tpl.h.

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

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 671 of file O3ClassFactory_tpl.h.

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

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

Referenced by _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 682 of file O3ClassFactory_tpl.h.

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

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

Referenced by _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 644 of file O3ClassFactory_tpl.h.

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

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 _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 156 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 1018 of file O3ClassFactory_tpl.h.

1018 {
1019 if (agg.parameters().size() != n) {
1020 O3PRM_CLASS_AGG_PARAMETERS(agg.name(), Size(n), Size(agg.parameters().size()), *_errors_);
1021 return false;
1022 }
1023
1024 return true;
1025 }
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

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

Referenced by _checkAggParameters_().

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 1028 of file O3ClassFactory_tpl.h.

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

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

Referenced by _checkAggParameters_().

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 633 of file O3ClassFactory_tpl.h.

634 {
635 if (prnt.label().find('.') == std::string::npos) {
636 return _checkLocalParent_(c, prnt);
637
638 } else {
639 return _checkRemoteParent_(c, prnt);
640 }
641 }
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_().

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 770 of file O3ClassFactory_tpl.h.

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

References _errors_, _prm_, _resolveSlotChain_(), 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_().

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 375 of file O3ClassFactory_tpl.h.

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

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_().

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 663 of file O3ClassFactory_tpl.h.

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

References _resolveSlotChain_().

Referenced by _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 750 of file O3ClassFactory_tpl.h.

751 {
752 const auto& scope = c.scope();
753 bool errors = false;
754 for (auto& rule: attr.rules()) {
755 try {
756 if (!_checkLabelsNumber_(attr, rule)) { errors = true; }
757 if (!_checkLabelsValues_(c, attr, rule)) { errors = true; }
759 if (!_checkRuleCPTSumsTo1_(c, attr, rule)) { errors = true; }
760 } catch (Exception& e) {
762 errors = true;
763 }
764 }
765
766 return errors == false;
767 }
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)
#define GUM_SHOWERROR(e)
Definition exceptions.h:89

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

Referenced by _checkAttributeForCompletion_().

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 719 of file O3ClassFactory_tpl.h.

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

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

Referenced by _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 874 of file O3ClassFactory_tpl.h.

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

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

Referenced by _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 544 of file O3ClassFactory_tpl.h.

545 {
546 // Attributes
547 for (auto& agg: c.aggregates()) {
549 factory.continueAggregator(agg.name().label());
550
551 for (const auto& parent: agg.parents()) {
552 factory.addParent(parent.label());
553 }
554
555 factory.endAggregator();
556 }
557 }
558 }
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 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 574 of file O3ClassFactory_tpl.h.

575 {
576 // Attributes
577 for (auto& attr: c.attributes()) {
579 factory.continueAttribute(attr->name().label());
580
581 for (const auto& parent: attr->parents()) {
582 factory.addParent(parent.label());
583 }
584
585 if (auto raw = dynamic_cast< const O3RawCPT* >(attr.get())) {
587 for (const auto& val: raw->values()) {
588 values.push_back(val.formula().formula());
589 }
590 factory.setRawCPFByColumns(values);
591 }
592
593 if (auto rule_cpt = dynamic_cast< const O3RuleCPT* >(attr.get())) {
594 for (const auto& rule: rule_cpt->rules()) {
597
598 for (const auto& lbl: rule.first) {
599 labels.push_back(lbl.label());
600 }
601
602 for (const auto& form: rule.second) {
603 values.push_back(form.formula().formula());
604 }
605
606 factory.setCPFByRule(labels, values);
607 }
608 }
609
610 factory.endAttribute();
611 }
612 }
613 }
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 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 886 of file O3ClassFactory_tpl.h.

886 {
888 factory.continueClass(c.name().label());
889
890 for (auto& agg: c.aggregates()) {
893 for (auto& p: agg.parameters()) {
894 params.push_back(p.label());
895 }
896
897 factory.startAggregator(agg.name().label(),
898 agg.aggregateType().label(),
899 agg.variableType().label(),
900 params);
901 factory.endAggregator();
902 }
903 }
904
905 factory.endClass(false);
906 }
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 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 450 of file O3ClassFactory_tpl.h.

450 {
452 factory.continueClass(c.name().label());
453
454 for (auto& attr: c.attributes()) {
456 factory.startAttribute(attr->type().label(), attr->name().label());
457 factory.endAttribute();
458 }
459 }
460
461 factory.endClass(false);
462 }
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 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 837 of file O3ClassFactory_tpl.h.

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

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

Referenced by _checkAggParents_(), _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 147 of file O3ClassFactory_tpl.h.

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

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 123 of file O3ClassFactory_tpl.h.

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

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 202 of file O3ClassFactory_tpl.h.

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

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 313 of file O3ClassFactory_tpl.h.

313 {
315 // Class with a super class must be declared after
316 for (auto c: _o3Classes_) {
317 _prm_->getClass(c->name().label()).inheritParameters();
318
319 factory.continueClass(c->name().label());
320
322
323 factory.endClass(false);
324 }
325 }
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 350 of file O3ClassFactory_tpl.h.

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

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 530 of file O3ClassFactory_tpl.h.

530 {
532
533 // Class with a super class must be declared in order
534 for (auto c: _o3Classes_) {
535 factory.continueClass(c->name().label());
536
538
539 factory.endClass(false);
540 }
541 }
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 488 of file O3ClassFactory_tpl.h.

488 {
490
491 // Class with a super class must be declared in order
492 for (auto c: _o3Classes_) {
493 _prm_->getClass(c->name().label()).inheritSlotChains();
494 factory.continueClass(c->name().label());
495
497
498 if (c->superLabel().label() != "") {
499 auto& super = _prm_->getClass(c->superLabel().label());
501
502 for (auto a: super.attributes()) {
503 to_complete.insert(a->safeName());
504 }
505
506 for (auto a: super.aggregates()) {
507 to_complete.insert(a->safeName());
508 }
509
510 for (auto& a: c->attributes()) {
511 to_complete.erase(
512 _prm_->getClass(c->name().label()).get(a->name().label()).safeName());
513 }
514
515 for (auto& a: c->aggregates()) {
516 to_complete.erase(
517 _prm_->getClass(c->name().label()).get(a.name().label()).safeName());
518 }
519
520 for (auto a: to_complete) {
521 _prm_->getClass(c->name().label()).completeInheritance(a);
522 }
523 }
524
525 factory.endClass(true);
526 }
527 }
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 441 of file O3ClassFactory_tpl.h.

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

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 432 of file O3ClassFactory_tpl.h.

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

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 92 of file O3ClassFactory_tpl.h.

92 {
93 if (this == &src) { return *this; }
94 _prm_ = src._prm_;
101 _dag_ = src._dag_;
103 return *this;
104 }

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 108 of file O3ClassFactory_tpl.h.

108 {
109 if (this == &src) { return *this; }
119 return *this;
120 }

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: