aGrUM  0.20.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 >:

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

Detailed Description

template<typename 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 58 of file O3ClassFactory.h.

Constructor & Destructor Documentation

◆ O3ClassFactory() [1/3]

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

Definition at line 37 of file O3ClassFactory_tpl.h.

41  :
42  prm__(&prm),
43  o3_prm__(&o3_prm), solver__(&solver), errors__(&errors) {
44  GUM_CONSTRUCTOR(O3ClassFactory);
45  }
O3NameSolver< GUM_SCALAR > * solver__
O3ClassFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)

◆ O3ClassFactory() [2/3]

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

Definition at line 48 of file O3ClassFactory_tpl.h.

49  :
50  prm__(src.prm__),
51  o3_prm__(src.o3_prm__), solver__(src.solver__), errors__(src.errors__),
52  nameMap__(src.nameMap__), classMap__(src.classMap__),
53  nodeMap__(src.nodeMap__), dag__(src.dag__),
54  o3Classes__(src.o3Classes__) {
55  GUM_CONS_CPY(O3ClassFactory);
56  }
O3NameSolver< GUM_SCALAR > * solver__
std::vector< O3Class *> o3Classes__
HashTable< std::string, gum::NodeId > nameMap__
HashTable< std::string, O3Class *> classMap__
O3ClassFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
HashTable< NodeId, O3Class *> nodeMap__

◆ O3ClassFactory() [3/3]

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

Definition at line 59 of file O3ClassFactory_tpl.h.

60  :
61  prm__(std::move(src.prm__)),
62  o3_prm__(std::move(src.o3_prm__)), solver__(std::move(src.solver__)),
63  errors__(std::move(src.errors__)), nameMap__(std::move(src.nameMap__)),
64  classMap__(std::move(src.classMap__)),
65  nodeMap__(std::move(src.nodeMap__)), dag__(std::move(src.dag__)),
66  o3Classes__(std::move(src.o3Classes__)) {
67  GUM_CONS_MOV(O3ClassFactory);
68  }
O3NameSolver< GUM_SCALAR > * solver__
std::vector< O3Class *> o3Classes__
HashTable< std::string, gum::NodeId > nameMap__
HashTable< std::string, O3Class *> classMap__
O3ClassFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
HashTable< NodeId, O3Class *> nodeMap__

◆ ~O3ClassFactory()

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

Definition at line 71 of file O3ClassFactory_tpl.h.

71  {
72  GUM_DESTRUCTOR(O3ClassFactory);
73  }
O3ClassFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)

Member Function Documentation

◆ addParameters__()

template<typename GUM_SCALAR >
INLINE void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::addParameters__ ( PRMFactory< GUM_SCALAR > &  factory,
O3Class c 
)
private

Definition at line 331 of file O3ClassFactory_tpl.h.

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

◆ addParamsToForms__()

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

Definition at line 734 of file O3ClassFactory_tpl.h.

736  {
737  // Add parameters to formulas
738  for (auto& f: rule.second) {
739  f.formula().variables().clear();
740  for (const auto& values: scope) {
741  f.formula().variables().insert(values.first, values.second->value());
742  }
743  }
744  }

◆ addReferenceSlots__()

template<typename GUM_SCALAR >
INLINE void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::addReferenceSlots__ ( O3Class c)
private

Definition at line 363 of file O3ClassFactory_tpl.h.

363  {
364  PRMFactory< GUM_SCALAR > factory(prm__);
365 
366  factory.continueClass(c.name().label());
367 
368  // References
369  for (auto& ref: c.referenceSlots()) {
370  if (checkReferenceSlot__(c, ref)) {
371  factory.addReferenceSlot(ref.type().label(),
372  ref.name().label(),
373  ref.isArray());
374  }
375  }
376 
377  factory.endClass(false);
378  }
bool checkReferenceSlot__(O3Class &c, O3ReferenceSlot &ref)

◆ buildClasses()

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

Definition at line 108 of file O3ClassFactory_tpl.h.

108  {
109  PRMFactory< GUM_SCALAR > factory(prm__);
110 
111  // Class with a super class must be declared after
112  if (checkO3Classes__()) {
114 
115  for (auto c: o3Classes__) {
116  // Soving interfaces
117  auto implements = Set< std::string >();
118  for (auto& i: c->interfaces()) {
119  if (solver__->resolveInterface(i)) { implements.insert(i.label()); }
120  }
121 
122  // Adding the class
123  if (solver__->resolveClass(c->superLabel())) {
124  factory.startClass(c->name().label(),
125  c->superLabel().label(),
126  &implements,
127  true);
128  factory.endClass(false);
129  }
130  }
131  }
132  }
O3NameSolver< GUM_SCALAR > * solver__
std::vector< O3Class *> o3Classes__
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:632

◆ buildImplementations()

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

Definition at line 190 of file O3ClassFactory_tpl.h.

190  {
191  for (auto& c: o3_prm__->classes()) {
192  if (checkImplementation__(*c)) {
193  prm__->getClass(c->name().label()).initializeInheritance();
194  }
195  }
196  }
O3ClassList & classes()
Definition: O3prm.cpp:502

◆ buildParameters()

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

Definition at line 316 of file O3ClassFactory_tpl.h.

316  {
317  PRMFactory< GUM_SCALAR > factory(prm__);
318  // Class with a super class must be declared after
319  for (auto c: o3Classes__) {
320  prm__->getClass(c->name().label()).inheritParameters();
321 
322  factory.continueClass(c->name().label());
323 
324  addParameters__(factory, *c);
325 
326  factory.endClass(false);
327  }
328  }
std::vector< O3Class *> o3Classes__
void addParameters__(PRMFactory< GUM_SCALAR > &factory, O3Class &c)

◆ buildReferenceSlots()

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

Definition at line 354 of file O3ClassFactory_tpl.h.

354  {
355  // Class with a super class must be declared after
356  for (auto c: o3Classes__) {
357  prm__->getClass(c->name().label()).inheritReferenceSlots();
359  }
360  }
std::vector< O3Class *> o3Classes__

◆ checkAggParameters__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAggParameters__ ( O3Class o3class,
O3Aggregate agg,
const PRMType t 
)
private

Definition at line 1031 of file O3ClassFactory_tpl.h.

1033  {
1034  bool ok = false;
1035 
1037  agg.aggregateType().label())) {
1045  ok = checkParametersNumber__(agg, 0);
1046  break;
1047  }
1048 
1052  ok = checkParametersNumber__(agg, 1);
1053  break;
1054  }
1055 
1056  default: {
1057  GUM_ERROR(FatalError, "unknown aggregate type");
1058  }
1059  }
1060 
1061  if (!ok) { return false; }
1062 
1063  // Checking parameters type
1065  agg.aggregateType().label())) {
1069  ok = checkParameterValue__(agg, *t);
1070  break;
1071  }
1072 
1073  default: { /* Nothing to do */
1074  }
1075  }
1076 
1077  return ok;
1078  }
bool checkParameterValue__(O3Aggregate &agg, const gum::prm::PRMType &t)
bool checkParametersNumber__(O3Aggregate &agg, Size n)
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ checkAggParents__()

template<typename GUM_SCALAR >
INLINE const PRMType * gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAggParents__ ( O3Class o3class,
O3Aggregate agg 
)
private

Definition at line 974 of file O3ClassFactory_tpl.h.

975  {
976  const auto& c = prm__->getClass(o3class.name().label());
977  auto t = (const PRMType*)nullptr;
978 
979  for (const auto& prnt: agg.parents()) {
980  auto elt = resolveSlotChain__(c, prnt);
981 
982  if (elt == nullptr) {
983  O3PRM_CLASS_PARENT_NOT_FOUND(prnt, *errors__);
984  return nullptr;
985 
986  } else {
987  if (t == nullptr) {
988  try {
989  t = &(elt->type());
990 
991  } catch (OperationNotAllowed&) {
992  O3PRM_CLASS_WRONG_PARENT(prnt, *errors__);
993  return nullptr;
994  }
995 
996  } else if ((*t) != elt->type()) {
997  // Wront type in chain
998  O3PRM_CLASS_WRONG_PARENT_TYPE(prnt,
999  t->name(),
1000  elt->type().name(),
1001  *errors__);
1002  return nullptr;
1003  }
1004  }
1005  }
1006  return t;
1007  }
const PRMClassElement< GUM_SCALAR > * resolveSlotChain__(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain)

◆ checkAggregateForCompletion__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAggregateForCompletion__ ( O3Class o3class,
O3Aggregate agg 
)
private

Definition at line 574 of file O3ClassFactory_tpl.h.

576  {
577  // Checking parents
578  auto t = checkAggParents__(c, agg);
579  if (t == nullptr) { return false; }
580 
581  // Checking parameters numbers
582  if (!checkAggParameters__(c, agg, t)) { return false; }
583 
584  return true;
585  }
bool checkAggParameters__(O3Class &o3class, O3Aggregate &agg, const PRMType *t)
const PRMType * checkAggParents__(O3Class &o3class, O3Aggregate &agg)

◆ checkAggregateForDeclaration__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAggregateForDeclaration__ ( O3Class o3class,
O3Aggregate agg 
)
private

Definition at line 961 of file O3ClassFactory_tpl.h.

963  {
964  if (!solver__->resolveType(agg.variableType())) { return false; }
965 
966  // Checking type legality if overload
967  if (!checkAggTypeLegality__(o3class, agg)) { return false; }
968 
969  return true;
970  }
O3NameSolver< GUM_SCALAR > * solver__
bool checkAggTypeLegality__(O3Class &o3class, O3Aggregate &agg)

◆ checkAggTypeLegality__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAggTypeLegality__ ( O3Class o3class,
O3Aggregate agg 
)
private

Definition at line 1011 of file O3ClassFactory_tpl.h.

1012  {
1013  if (prm__->isClass(o3class.superLabel().label())) {
1014  const auto& super = prm__->getClass(o3class.superLabel().label());
1015  const auto& agg_type = prm__->type(agg.variableType().label());
1016 
1017  if (super.exists(agg.name().label())
1018  && !agg_type.isSubTypeOf(super.get(agg.name().label()).type())) {
1019  O3PRM_CLASS_ILLEGAL_OVERLOAD(agg.name(),
1020  o3class.superLabel(),
1021  *errors__);
1022  return false;
1023  }
1024  }
1025 
1026  return true;
1027  }

◆ checkAndAddArcsToDag__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAndAddArcsToDag__ ( )
private

Definition at line 168 of file O3ClassFactory_tpl.h.

168  {
169  for (auto& c: o3_prm__->classes()) {
170  if (c->superLabel().label() != "") {
171  if (!solver__->resolveClass(c->superLabel())) { return false; }
172 
173  auto head = nameMap__[c->superLabel().label()];
174  auto tail = nameMap__[c->name().label()];
175 
176  try {
177  dag__.addArc(tail, head);
178  } catch (InvalidDirectedCycle&) {
179  // Cyclic inheritance
180  O3PRM_CLASS_CYLIC_INHERITANCE(c->name(), c->superLabel(), *errors__);
181  return false;
182  }
183  }
184  }
185 
186  return true;
187  }
O3ClassList & classes()
Definition: O3prm.cpp:502
O3NameSolver< GUM_SCALAR > * solver__
void addArc(NodeId tail, NodeId head) final
insert a new arc into the directed graph
Definition: DAG_inl.h:42
HashTable< std::string, gum::NodeId > nameMap__

◆ checkAndAddNodesToDag__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAndAddNodesToDag__ ( )
private

Definition at line 149 of file O3ClassFactory_tpl.h.

149  {
150  for (auto& c: o3_prm__->classes()) {
151  auto id = dag__.addNode();
152 
153  try {
154  nameMap__.insert(c->name().label(), id);
155  classMap__.insert(c->name().label(), c.get());
156  nodeMap__.insert(id, c.get());
157 
158  } catch (DuplicateElement&) {
159  O3PRM_CLASS_DUPLICATE(c->name(), *errors__);
160  return false;
161  }
162  }
163 
164  return true;
165  }
O3ClassList & classes()
Definition: O3prm.cpp:502
HashTable< std::string, gum::NodeId > nameMap__
HashTable< std::string, O3Class *> classMap__
virtual NodeId addNode()
insert a new node and return its id
HashTable< NodeId, O3Class *> nodeMap__
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.

◆ checkAttributeForCompletion__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAttributeForCompletion__ ( const O3Class o3_c,
O3Attribute attr 
)
private

Definition at line 634 of file O3ClassFactory_tpl.h.

636  {
637  // Check for parents existence
638  const auto& c = prm__->getClass(o3_c.name().label());
639  for (auto& prnt: attr.parents()) {
640  if (!checkParent__(c, prnt)) { return false; }
641  }
642 
643  // Check that CPT sums to 1
644  auto raw = dynamic_cast< O3RawCPT* >(&attr);
645  if (raw) { return checkRawCPT__(c, *raw); }
646 
647  auto rule = dynamic_cast< O3RuleCPT* >(&attr);
648  if (rule) { return checkRuleCPT__(c, *rule); }
649 
650  return true;
651  }
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)

◆ checkAttributeForDeclaration__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAttributeForDeclaration__ ( O3Class o3_c,
O3Attribute attr 
)
private

Definition at line 474 of file O3ClassFactory_tpl.h.

476  {
477  // Check type
478  if (!solver__->resolveType(attr.type())) { return false; }
479 
480  // Checking type legality if overload
481  if (c.superLabel().label() != "") {
482  const auto& super = prm__->getClass(c.superLabel().label());
483 
484  if (!super.exists(attr.name().label())) { return true; }
485 
486  const auto& super_type = super.get(attr.name().label()).type();
487  const auto& type = prm__->type(attr.type().label());
488 
489  if (!type.isSubTypeOf(super_type)) {
490  O3PRM_CLASS_ILLEGAL_OVERLOAD(attr.name(), c.superLabel(), *errors__);
491  return false;
492  }
493  }
494  return true;
495  }
O3NameSolver< GUM_SCALAR > * solver__

◆ checkImplementation__() [1/4]

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkImplementation__ ( O3Class c)
private

Definition at line 203 of file O3ClassFactory_tpl.h.

203  {
204  // Saving attributes names for fast lookup
205  auto attr_map = AttrMap();
206  for (auto& a: c.attributes()) {
207  attr_map.insert(a->name().label(), a.get());
208  }
209 
210  // Saving aggregates names for fast lookup
211  auto agg_map = AggMap();
212  for (auto& agg: c.aggregates()) {
213  agg_map.insert(agg.name().label(), &agg);
214  }
215 
216  auto ref_map = RefMap();
217  for (auto& ref: c.referenceSlots()) {
218  ref_map.insert(ref.name().label(), &ref);
219  }
220 
221  // Cheking interface implementation
222  for (auto& i: c.interfaces()) {
223  if (solver__->resolveInterface(i)) {
224  if (!checkImplementation__(c, i, attr_map, agg_map, ref_map)) {
225  return false;
226  }
227  }
228  }
229 
230  return true;
231  }
O3NameSolver< GUM_SCALAR > * solver__
HashTable< std::string, O3Attribute *> AttrMap
HashTable< std::string, O3Aggregate *> AggMap
HashTable< std::string, O3ReferenceSlot *> RefMap

◆ checkImplementation__() [2/4]

template<typename 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<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkImplementation__ ( O3Label o3_type,
const PRMType type 
)
private

Definition at line 295 of file O3ClassFactory_tpl.h.

296  {
297  if (!solver__->resolveType(o3_type)) { return false; }
298 
299  return prm__->type(o3_type.label()).isSubTypeOf(type);
300  }
O3NameSolver< GUM_SCALAR > * solver__

◆ checkImplementation__() [4/4]

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

Definition at line 303 of file O3ClassFactory_tpl.h.

305  {
306  if (!solver__->resolveSlotType(o3_type)) { return false; }
307 
308  if (prm__->isInterface(o3_type.label())) {
309  return prm__->getInterface(o3_type.label()).isSubTypeOf(type);
310  } else {
311  return prm__->getClass(o3_type.label()).isSubTypeOf(type);
312  }
313  }
O3NameSolver< GUM_SCALAR > * solver__

◆ checkLabelsNumber__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkLabelsNumber__ ( const O3RuleCPT attr,
const O3RuleCPT::O3Rule rule 
)
private

Definition at line 694 of file O3ClassFactory_tpl.h.

696  {
697  // Check that the number of labels is correct
698  if (rule.first.size() != attr.parents().size()) {
699  O3PRM_CLASS_ILLEGAL_RULE_SIZE(rule,
700  rule.first.size(),
701  attr.parents().size(),
702  *errors__);
703  return false;
704  }
705  return true;
706  }

◆ checkLabelsValues__()

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

Definition at line 709 of file O3ClassFactory_tpl.h.

712  {
713  bool errors = false;
714  for (std::size_t i = 0; i < attr.parents().size(); ++i) {
715  auto label = rule.first[i];
716  auto prnt = attr.parents()[i];
717  try {
718  auto real_labels = resolveSlotChain__(c, prnt)->type()->labels();
719  // c.get(prnt.label()).type()->labels();
720  if (label.label() != "*"
721  && std::find(real_labels.begin(), real_labels.end(), label.label())
722  == real_labels.end()) {
723  O3PRM_CLASS_ILLEGAL_RULE_LABEL(rule, label, prnt, *errors__);
724  errors = true;
725  }
726  } catch (Exception&) {
727  // parent does not exists and is already reported
728  }
729  }
730  return errors == false;
731  }
const PRMClassElement< GUM_SCALAR > * resolveSlotChain__(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain)

◆ checkLocalParent__()

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

Definition at line 666 of file O3ClassFactory_tpl.h.

668  {
669  if (!c.exists(prnt.label())) {
670  O3PRM_CLASS_PARENT_NOT_FOUND(prnt, *errors__);
671  return false;
672  }
673 
674  const auto& elt = c.get(prnt.label());
678  O3PRM_CLASS_ILLEGAL_PARENT(prnt, *errors__);
679  return false;
680  }
681 
682  return true;
683  }
Abstract class representing an element of PRM class.

◆ checkO3Classes__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkO3Classes__ ( )
private

Definition at line 144 of file O3ClassFactory_tpl.h.

◆ checkParametersNumber__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkParametersNumber__ ( O3Aggregate agg,
Size  n 
)
private

Definition at line 1082 of file O3ClassFactory_tpl.h.

1083  {
1084  if (agg.parameters().size() != n) {
1085  O3PRM_CLASS_AGG_PARAMETERS(agg.name(),
1086  Size(n),
1087  Size(agg.parameters().size()),
1088  *errors__);
1089  return false;
1090  }
1091 
1092  return true;
1093  }
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47

◆ checkParameterValue__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkParameterValue__ ( O3Aggregate agg,
const gum::prm::PRMType t 
)
private

Definition at line 1096 of file O3ClassFactory_tpl.h.

1098  {
1099  const auto& param = agg.parameters().front();
1100  bool found = false;
1101  for (Size idx = 0; idx < t.variable().domainSize(); ++idx) {
1102  if (t.variable().label(idx) == param.label()) {
1103  found = true;
1104  break;
1105  }
1106  }
1107 
1108  if (!found) {
1109  O3PRM_CLASS_AGG_PARAMETER_NOT_FOUND(agg.name(), param, *errors__);
1110  return false;
1111  }
1112 
1113  return true;
1114  }
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
Definition: PRMType_inl.h:44
virtual Size domainSize() const =0
virtual std::string label(Idx i) const =0
get the indice-th label. This method is pure virtual.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47

◆ checkParent__()

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

Definition at line 654 of file O3ClassFactory_tpl.h.

656  {
657  if (prnt.label().find('.') == std::string::npos) {
658  return checkLocalParent__(c, prnt);
659 
660  } else {
661  return checkRemoteParent__(c, prnt);
662  }
663  }
bool checkLocalParent__(const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
bool checkRemoteParent__(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &prnt)

◆ checkRawCPT__()

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

Definition at line 807 of file O3ClassFactory_tpl.h.

809  {
810  const auto& type = prm__->type(attr.type().label());
811 
812  auto domainSize = type->domainSize();
813  for (auto& prnt: attr.parents()) {
814  try {
815  domainSize *= c.get(prnt.label()).type()->domainSize();
816  } catch (NotFound&) {
817  // If we are here, all parents have been check so resolveSlotChain__
818  // will not raise an error and not return a nullptr
819  domainSize *= resolveSlotChain__(c, prnt)->type()->domainSize();
820  }
821  }
822 
823  // Check for CPT size
824  if (domainSize != attr.values().size()) {
825  O3PRM_CLASS_ILLEGAL_CPT_SIZE(c.name(),
826  attr.name(),
827  Size(attr.values().size()),
828  domainSize,
829  *errors__);
830  return false;
831  }
832 
833  // Add parameters to formulas
834  const auto& scope = c.scope();
835  for (auto& f: attr.values()) {
836  f.formula().variables().clear();
837 
838  for (const auto& values: scope) {
839  f.formula().variables().insert(values.first, values.second->value());
840  }
841  }
842 
843  // Check that CPT sums to 1
844  Size parent_size = domainSize / type->domainSize();
845  auto values = std::vector< GUM_SCALAR >(parent_size, 0.0f);
846 
847  for (std::size_t i = 0; i < attr.values().size(); ++i) {
848  try {
849  auto idx = i % parent_size;
850  auto val = (GUM_SCALAR)attr.values()[i].formula().result();
851  values[idx] += val;
852 
853  if (val < 0.0 || 1.0 < val) {
854  O3PRM_CLASS_ILLEGAL_CPT_VALUE(c.name(),
855  attr.name(),
856  attr.values()[i],
857  *errors__);
858  return false;
859  }
860  } catch (Exception&) {
861  O3PRM_CLASS_ILLEGAL_CPT_VALUE(c.name(),
862  attr.name(),
863  attr.values()[i],
864  *errors__);
865  return false;
866  }
867  }
868 
869  for (auto f: values) {
870  if (std::abs(f - GUM_SCALAR(1.0)) > 1.0e-3) {
871  O3PRM_CLASS_CPT_DOES_NOT_SUM_TO_1(c.name(),
872  attr.name(),
873  float(f),
874  *errors__);
875  return false;
876  } else if (std::abs(f - GUM_SCALAR(1.0)) > 1.0e-6) {
877  O3PRM_CLASS_CPT_DOES_NOT_SUM_TO_1_WARNING(c.name(),
878  attr.name(),
879  float(f),
880  *errors__);
881  }
882  }
883  return true;
884  }
Potential< GUM_SCALAR > abs(const Potential< GUM_SCALAR > &arg)
Definition: potential.h:617
const PRMClassElement< GUM_SCALAR > * resolveSlotChain__(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47

◆ checkReferenceSlot__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkReferenceSlot__ ( O3Class c,
O3ReferenceSlot ref 
)
private

Definition at line 382 of file O3ClassFactory_tpl.h.

383  {
384  if (!solver__->resolveSlotType(ref.type())) { return false; }
385 
386  const auto& real_c = prm__->getClass(c.name().label());
387 
388  // Check for dupplicates
389  if (real_c.exists(ref.name().label())) {
390  const auto& elt = real_c.get(ref.name().label());
391 
393  auto slot_type = (PRMClassElementContainer< GUM_SCALAR >*)nullptr;
394 
395  if (prm__->isInterface(ref.type().label())) {
396  slot_type = &(prm__->getInterface(ref.type().label()));
397 
398  } else {
399  slot_type = &(prm__->getClass(ref.type().label()));
400  }
401 
402  auto real_ref
403  = static_cast< const PRMReferenceSlot< GUM_SCALAR >* >(&elt);
404 
405  if (slot_type->name() == real_ref->slotType().name()) {
406  O3PRM_CLASS_DUPLICATE_REFERENCE(ref.name(), *errors__);
407  return false;
408 
409  } else if (!slot_type->isSubTypeOf(real_ref->slotType())) {
410  O3PRM_CLASS_ILLEGAL_OVERLOAD(ref.name(), c.name(), *errors__);
411  return false;
412  }
413 
414  } else {
415  O3PRM_CLASS_DUPLICATE_REFERENCE(ref.name(), *errors__);
416  return false;
417  }
418  }
419 
420  // If class we need to check for illegal references
421  if (prm__->isClass(ref.type().label())) {
422  const auto& ref_type = prm__->getClass(ref.type().label());
423 
424  // No recursive reference
425  if ((&ref_type) == (&real_c)) {
426  O3PRM_CLASS_SELF_REFERENCE(c.name(), ref.name(), *errors__);
427  return false;
428  }
429 
430  // No reference to subclasses
431  if (ref_type.isSubTypeOf(real_c)) {
432  O3PRM_CLASS_ILLEGAL_SUB_REFERENCE(c.name(), ref.type(), *errors__);
433  return false;
434  }
435  }
436 
437  return true;
438  }
O3NameSolver< GUM_SCALAR > * solver__
static INLINE bool isReferenceSlot(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMReferenceSlot.

◆ checkRemoteParent__()

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

Definition at line 686 of file O3ClassFactory_tpl.h.

688  {
689  if (resolveSlotChain__(c, prnt) == nullptr) { return false; }
690  return true;
691  }
const PRMClassElement< GUM_SCALAR > * resolveSlotChain__(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain)

◆ checkRuleCPT__()

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

Definition at line 786 of file O3ClassFactory_tpl.h.

788  {
789  const auto& scope = c.scope();
790  bool errors = false;
791  for (auto& rule: attr.rules()) {
792  try {
793  if (!checkLabelsNumber__(attr, rule)) { errors = true; }
794  if (!checkLabelsValues__(c, attr, rule)) { errors = true; }
795  addParamsToForms__(scope, rule);
796  if (!checkRuleCPTSumsTo1__(c, attr, rule)) { errors = true; }
797  } catch (Exception& e) {
798  GUM_SHOWERROR(e);
799  errors = true;
800  }
801  }
802 
803  return errors == false;
804  }
#define GUM_SHOWERROR(e)
Definition: exceptions.h:60
bool checkRuleCPTSumsTo1__(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 checkLabelsValues__(const PRMClass< GUM_SCALAR > &c, const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
bool checkLabelsNumber__(const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)

◆ checkRuleCPTSumsTo1__()

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

Definition at line 748 of file O3ClassFactory_tpl.h.

751  {
752  bool errors = false;
753  // Check that formulas are valid and sums to 1
754  GUM_SCALAR sum = 0.0;
755  for (const auto& f: rule.second) {
756  try {
757  auto value = GUM_SCALAR(f.formula().result());
758  sum += value;
759  if (value < 0.0 || 1.0 < value) {
760  O3PRM_CLASS_ILLEGAL_CPT_VALUE(c.name(), attr.name(), f, *errors__);
761  errors = true;
762  }
763  } catch (OperationNotAllowed&) {
764  O3PRM_CLASS_ILLEGAL_CPT_VALUE(c.name(), attr.name(), f, *errors__);
765  errors = true;
766  }
767  }
768 
769  // Check that CPT sums to 1
770  if (std::abs(sum - 1.0) > 1e-3) {
771  O3PRM_CLASS_CPT_DOES_NOT_SUM_TO_1(c.name(),
772  attr.name(),
773  float(sum),
774  *errors__);
775  errors = true;
776  } else if (std::abs(sum - 1.0f) > 1e-6) {
777  O3PRM_CLASS_CPT_DOES_NOT_SUM_TO_1_WARNING(c.name(),
778  attr.name(),
779  float(sum),
780  *errors__);
781  }
782  return errors == false;
783  }
Potential< GUM_SCALAR > abs(const Potential< GUM_SCALAR > &arg)
Definition: potential.h:617

◆ checkSlotChainLink__()

template<typename GUM_SCALAR >
INLINE bool gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkSlotChainLink__ ( const PRMClassElementContainer< GUM_SCALAR > &  c,
const O3Label chain,
const std::string &  s 
)
private

Definition at line 926 of file O3ClassFactory_tpl.h.

929  {
930  if (!c.exists(s)) {
931  O3PRM_CLASS_LINK_NOT_FOUND(chain, s, *errors__);
932  return false;
933  }
934  return true;
935  }

◆ completeAggregates()

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

Definition at line 542 of file O3ClassFactory_tpl.h.

542  {
543  PRMFactory< GUM_SCALAR > factory(prm__);
544 
545  // Class with a super class must be declared in order
546  for (auto c: o3Classes__) {
547  factory.continueClass(c->name().label());
548 
549  completeAggregates__(factory, *c);
550 
551  factory.endClass(false);
552  }
553  }
void completeAggregates__(PRMFactory< GUM_SCALAR > &factory, O3Class &c)
std::vector< O3Class *> o3Classes__

◆ completeAggregates__()

template<typename GUM_SCALAR >
INLINE void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::completeAggregates__ ( PRMFactory< GUM_SCALAR > &  factory,
O3Class c 
)
private

Definition at line 556 of file O3ClassFactory_tpl.h.

558  {
559  // Attributes
560  for (auto& agg: c.aggregates()) {
561  if (checkAggregateForCompletion__(c, agg)) {
562  factory.continueAggregator(agg.name().label());
563 
564  for (const auto& parent: agg.parents()) {
565  factory.addParent(parent.label());
566  }
567 
568  factory.endAggregator();
569  }
570  }
571  }
bool checkAggregateForCompletion__(O3Class &o3class, O3Aggregate &agg)

◆ completeAttribute__()

template<typename GUM_SCALAR >
INLINE void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::completeAttribute__ ( PRMFactory< GUM_SCALAR > &  factory,
O3Class c 
)
private

Definition at line 588 of file O3ClassFactory_tpl.h.

590  {
591  // Attributes
592  for (auto& attr: c.attributes()) {
593  if (checkAttributeForCompletion__(c, *attr)) {
594  factory.continueAttribute(attr->name().label());
595 
596  for (const auto& parent: attr->parents()) {
597  factory.addParent(parent.label());
598  }
599 
600  auto raw = dynamic_cast< const O3RawCPT* >(attr.get());
601 
602  if (raw) {
603  auto values = std::vector< std::string >();
604  for (const auto& val: raw->values()) {
605  values.push_back(val.formula().formula());
606  }
607  factory.setRawCPFByColumns(values);
608  }
609 
610  auto rule_cpt = dynamic_cast< const O3RuleCPT* >(attr.get());
611  if (rule_cpt) {
612  for (const auto& rule: rule_cpt->rules()) {
613  auto labels = std::vector< std::string >();
614  auto values = std::vector< std::string >();
615 
616  for (const auto& lbl: rule.first) {
617  labels.push_back(lbl.label());
618  }
619 
620  for (const auto& form: rule.second) {
621  values.push_back(form.formula().formula());
622  }
623 
624  factory.setCPFByRule(labels, values);
625  }
626  }
627 
628  factory.endAttribute();
629  }
630  }
631  }
bool checkAttributeForCompletion__(const O3Class &o3_c, O3Attribute &attr)

◆ completeAttributes()

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

Definition at line 498 of file O3ClassFactory_tpl.h.

498  {
499  PRMFactory< GUM_SCALAR > factory(prm__);
500 
501  // Class with a super class must be declared in order
502  for (auto c: o3Classes__) {
503  prm__->getClass(c->name().label()).inheritSlotChains();
504  factory.continueClass(c->name().label());
505 
506  completeAttribute__(factory, *c);
507 
508  if (c->superLabel().label() != "") {
509  auto& super = prm__->getClass(c->superLabel().label());
510  auto to_complete = Set< std::string >();
511 
512  for (auto a: super.attributes()) {
513  to_complete.insert(a->safeName());
514  }
515 
516  for (auto a: super.aggregates()) {
517  to_complete.insert(a->safeName());
518  }
519 
520  for (auto& a: c->attributes()) {
521  to_complete.erase(prm__->getClass(c->name().label())
522  .get(a->name().label())
523  .safeName());
524  }
525 
526  for (auto& a: c->aggregates()) {
527  to_complete.erase(prm__->getClass(c->name().label())
528  .get(a.name().label())
529  .safeName());
530  }
531 
532  for (auto a: to_complete) {
533  prm__->getClass(c->name().label()).completeInheritance(a);
534  }
535  }
536 
537  factory.endClass(true);
538  }
539  }
std::vector< O3Class *> o3Classes__
void completeAttribute__(PRMFactory< GUM_SCALAR > &factory, O3Class &c)
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:632

◆ declareAggregates()

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

Definition at line 450 of file O3ClassFactory_tpl.h.

450  {
451  // Class with a super class must be declared after
452  for (auto c: o3Classes__) {
453  prm__->getClass(c->name().label()).inheritAggregates();
455  }
456  }
std::vector< O3Class *> o3Classes__

◆ declareAggregates__()

template<typename GUM_SCALAR >
INLINE void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::declareAggregates__ ( O3Class c)
private

Definition at line 938 of file O3ClassFactory_tpl.h.

938  {
939  PRMFactory< GUM_SCALAR > factory(prm__);
940  factory.continueClass(c.name().label());
941 
942  for (auto& agg: c.aggregates()) {
943  if (checkAggregateForDeclaration__(c, agg)) {
944  auto params = std::vector< std::string >();
945  for (auto& p: agg.parameters()) {
946  params.push_back(p.label());
947  }
948 
949  factory.startAggregator(agg.name().label(),
950  agg.aggregateType().label(),
951  agg.variableType().label(),
952  params);
953  factory.endAggregator();
954  }
955  }
956 
957  factory.endClass(false);
958  }
bool checkAggregateForDeclaration__(O3Class &o3class, O3Aggregate &agg)

◆ declareAttribute__()

template<typename GUM_SCALAR >
INLINE void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::declareAttribute__ ( O3Class c)
private

Definition at line 459 of file O3ClassFactory_tpl.h.

459  {
460  PRMFactory< GUM_SCALAR > factory(prm__);
461  factory.continueClass(c.name().label());
462 
463  for (auto& attr: c.attributes()) {
464  if (checkAttributeForDeclaration__(c, *attr)) {
465  factory.startAttribute(attr->type().label(), attr->name().label());
466  factory.endAttribute();
467  }
468  }
469 
470  factory.endClass(false);
471  }
bool checkAttributeForDeclaration__(O3Class &o3_c, O3Attribute &attr)

◆ declareAttributes()

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

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()).inheritAttributes();
445  declareAttribute__(*c);
446  }
447  }
std::vector< O3Class *> o3Classes__

◆ operator=() [1/2]

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

Definition at line 76 of file O3ClassFactory_tpl.h.

77  {
78  if (this == &src) { return *this; }
79  prm__ = src.prm__;
80  o3_prm__ = src.o3_prm__;
81  solver__ = src.solver__;
82  errors__ = src.errors__;
83  nameMap__ = src.nameMap__;
84  classMap__ = src.classMap__;
85  nodeMap__ = src.nodeMap__;
86  dag__ = src.dag__;
87  o3Classes__ = src.o3Classes__;
88  return *this;
89  }
O3NameSolver< GUM_SCALAR > * solver__
std::vector< O3Class *> o3Classes__
HashTable< std::string, gum::NodeId > nameMap__
HashTable< std::string, O3Class *> classMap__
HashTable< NodeId, O3Class *> nodeMap__

◆ operator=() [2/2]

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

Definition at line 92 of file O3ClassFactory_tpl.h.

93  {
94  if (this == &src) { return *this; }
95  prm__ = std::move(src.prm__);
96  o3_prm__ = std::move(src.o3_prm__);
97  solver__ = std::move(src.solver__);
98  errors__ = std::move(src.errors__);
99  nameMap__ = std::move(src.nameMap__);
100  classMap__ = std::move(src.classMap__);
101  nodeMap__ = std::move(src.nodeMap__);
102  dag__ = std::move(src.dag__);
103  o3Classes__ = std::move(src.o3Classes__);
104  return *this;
105  }
O3NameSolver< GUM_SCALAR > * solver__
std::vector< O3Class *> o3Classes__
HashTable< std::string, gum::NodeId > nameMap__
HashTable< std::string, O3Class *> classMap__
HashTable< NodeId, O3Class *> nodeMap__

◆ resolveSlotChain__()

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

Definition at line 888 of file O3ClassFactory_tpl.h.

890  {
891  auto s = chain.label();
892  auto current = &c;
893  std::vector< std::string > v;
894 
895  decomposePath(chain.label(), v);
896 
897  for (size_t i = 0; i < v.size(); ++i) {
898  auto link = v[i];
899 
900  if (!checkSlotChainLink__(*current, chain, link)) { return nullptr; }
901 
902  auto elt = &(current->get(link));
903 
904  if (i == v.size() - 1) {
905  // last link, should be an attribute or aggregate
906  return elt;
907 
908  } else {
909  // should be a reference slot
910 
911  auto ref = dynamic_cast< const PRMReferenceSlot< GUM_SCALAR >* >(elt);
912  if (ref) {
913  current = &(ref->slotType());
914  } else {
915  return nullptr; // failsafe to prevent infinite loop
916  }
917  }
918  }
919 
920  // Encountered only reference slots
921 
922  return nullptr;
923  }
bool checkSlotChainLink__(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain, const std::string &s)
void decomposePath(const std::string &path, std::vector< std::string > &v)
Decompose a string in a vector of strings using "." as separators.
Definition: utils_prm.cpp:28

◆ setO3ClassCreationOrder__()

template<typename GUM_SCALAR >
INLINE void gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::setO3ClassCreationOrder__ ( )
private

Definition at line 135 of file O3ClassFactory_tpl.h.

135  {
136  auto topo_order = dag__.topologicalOrder();
137 
138  for (auto id = topo_order.rbegin(); id != topo_order.rend(); --id) {
139  o3Classes__.push_back(nodeMap__[*id]);
140  }
141  }
std::vector< O3Class *> o3Classes__
const Sequence< NodeId > & topologicalOrder(bool clear=true) const
The topological order stays the same as long as no variable or arcs are added or erased src the topol...
Definition: diGraph.cpp:90
HashTable< NodeId, O3Class *> nodeMap__

Member Data Documentation

◆ classMap__

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

Definition at line 96 of file O3ClassFactory.h.

◆ dag__

template<typename GUM_SCALAR >
DAG gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::dag__
private

Definition at line 98 of file O3ClassFactory.h.

◆ errors__

template<typename GUM_SCALAR >
ErrorsContainer* gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::errors__
private

Definition at line 93 of file O3ClassFactory.h.

◆ nameMap__

template<typename GUM_SCALAR >
HashTable< std::string, gum::NodeId > gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::nameMap__
private

Definition at line 95 of file O3ClassFactory.h.

◆ nodeMap__

template<typename GUM_SCALAR >
HashTable< NodeId, O3Class* > gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::nodeMap__
private

Definition at line 97 of file O3ClassFactory.h.

◆ o3_prm__

template<typename GUM_SCALAR >
O3PRM* gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::o3_prm__
private

Definition at line 91 of file O3ClassFactory.h.

◆ o3Classes__

template<typename GUM_SCALAR >
std::vector< O3Class* > gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::o3Classes__
private

Definition at line 99 of file O3ClassFactory.h.

◆ prm__

template<typename GUM_SCALAR >
PRM< GUM_SCALAR >* gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::prm__
private

Definition at line 90 of file O3ClassFactory.h.

◆ solver__

template<typename GUM_SCALAR >
O3NameSolver< GUM_SCALAR >* gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::solver__
private

Definition at line 92 of file O3ClassFactory.h.


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