aGrUM  0.16.0
O3ClassFactory.h
Go to the documentation of this file.
1 
31 #include <algorithm>
32 #include <memory>
33 #include <string>
34 
35 #include <agrum/PRM/PRM.h>
36 #include <agrum/PRM/PRMFactory.h>
38 #include <agrum/PRM/o3prm/O3prm.h>
39 #include <agrum/core/hashTable.h>
40 #include <agrum/core/set.h>
41 
42 #ifndef GUM_PRM_O3PRM_O3CLASS_FACTORY_H
43 # define GUM_PRM_O3PRM_O3CLASS_FACTORY_H
44 
45 namespace gum {
46  namespace prm {
47  namespace o3prm {
48 
58  template < typename GUM_SCALAR >
60  public:
62  O3PRM& o3_prm,
64  ErrorsContainer& errors);
72 
73  void buildClasses();
74 
75  void buildImplementations();
76 
77  void buildParameters();
78 
79  void buildReferenceSlots();
80 
81  void declareAggregates();
82 
83  void completeAggregates();
84 
85  void declareAttributes();
86 
87  void completeAttributes();
88 
89 
90  private:
95 
100  std::vector< O3Class* > __o3Classes;
101 
105 
107 
108  bool __checkAndAddArcsToDag();
109 
110  bool __checkO3Classes();
112 
116 
118  O3Class& c,
119  O3Label& i,
123 
124  bool __checkImplementation(O3Label& o3_type, const PRMType& type);
125 
127  O3Label& o3_type, const PRMClassElementContainer< GUM_SCALAR >& type);
129 
133 
135 
138  void __addReferenceSlots(O3Class& c);
139 
140 
143 
146  void __declareAttribute(O3Class& c);
147 
149 
151 
152  bool __checkAttributeForCompletion(const O3Class& o3_c, O3Attribute& attr);
153 
154  bool __checkParent(const PRMClass< GUM_SCALAR >& c, const O3Label& prnt);
155 
157  const O3Label& prnt);
158 
160  const O3Label& prnt);
161 
162  bool __checkRawCPT(const PRMClass< GUM_SCALAR >& c, O3RawCPT& attr);
163 
164  bool __checkRuleCPT(const PRMClass< GUM_SCALAR >& c, O3RuleCPT& attr);
165 
166  bool __checkLabelsNumber(const O3RuleCPT& attr,
167  const O3RuleCPT::O3Rule& rule);
168 
170  const O3RuleCPT& attr,
171  const O3RuleCPT::O3Rule& rule);
172 
173  void __addParamsToForms(
174  const HashTable< std::string, const PRMParameter< GUM_SCALAR >* >&
175  scope,
176  O3RuleCPT::O3Rule& rule);
177 
179  const O3RuleCPT& attr,
180  const O3RuleCPT::O3Rule& rule);
181 
183 
188  const O3Label& chain);
189 
191  const O3Label& chain,
192  const std::string& s);
194 
197  void __declareAggregates(O3Class& c);
199 
202 
203  const PRMType* __checkAggParents(O3Class& o3class, O3Aggregate& agg);
204 
205  bool __checkAggTypeLegality(O3Class& o3class, O3Aggregate& agg);
206 
207 
208  bool __checkAggParameters(O3Class& o3class,
209  O3Aggregate& agg,
210  const PRMType* t);
211 
213 
215 
216  // @}
217  };
218 
219  } // namespace o3prm
220  } // namespace prm
221 } // namespace gum
222 
223 // always include the implementation of the templates
225 
226 
227 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
228 extern template class gum::prm::o3prm::O3ClassFactory< double >;
229 # endif
230 
231 
232 #endif // GUM_PRM_O3PRM_O3CLASS_FACTORY_H
std::pair< O3LabelList, O3FormulaList > O3Rule
Definition: O3prm.h:546
bool __checkAggregateForDeclaration(O3Class &o3class, O3Aggregate &agg)
PRMParameter is a member of a Class in a PRM.
Definition: PRMParameter.h:52
bool __checkLabelsValues(const PRMClass< GUM_SCALAR > &c, const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
bool __checkAttributeForCompletion(const O3Class &o3_c, O3Attribute &attr)
void __addParamsToForms(const HashTable< std::string, const PRMParameter< GUM_SCALAR > * > &scope, O3RuleCPT::O3Rule &rule)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool __checkAttributeForDeclaration(O3Class &o3_c, O3Attribute &attr)
bool __checkRawCPT(const PRMClass< GUM_SCALAR > &c, O3RawCPT &attr)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The O3Aggregate is part of the AST of the O3PRM language.
Definition: O3prm.h:577
bool __checkReferenceSlot(O3Class &c, O3ReferenceSlot &ref)
Abstract class representing an element of PRM class.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
This class is used contain and manipulate gum::ParseError.
The O3Label is part of the AST of the O3PRM language.
Definition: O3prm.h:173
bool __checkParent(const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
The O3Attribute is part of the AST of the O3PRM language.
Definition: O3prm.h:471
void __completeAggregates(PRMFactory< GUM_SCALAR > &factory, O3Class &c)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
bool __checkLocalParent(const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
bool __checkRuleCPT(const PRMClass< GUM_SCALAR > &c, O3RuleCPT &attr)
bool __checkRemoteParent(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &prnt)
HashTable< std::string, gum::NodeId > __nameMap
void __completeAttribute(PRMFactory< GUM_SCALAR > &factory, O3Class &c)
The O3RuleCPT is part of the AST of the O3PRM language.
Definition: O3prm.h:542
Resolves names for the different O3PRM factories.
Definition: O3NameSolver.h:57
bool __checkAggTypeLegality(O3Class &o3class, O3Aggregate &agg)
bool __checkAggParameters(O3Class &o3class, O3Aggregate &agg, const PRMType *t)
The O3Class is part of the AST of the O3PRM language.
Definition: O3prm.h:619
O3ClassFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
bool __checkParameterValue(O3Aggregate &agg, const gum::prm::PRMType &t)
Factory which builds a PRM<GUM_SCALAR>.
Definition: PRMType.h:50
The O3ReferenceSlot is part of the AST of the O3PRM language.
Definition: O3prm.h:438
HashTable< NodeId, O3Class *> __nodeMap
bool __checkAggregateForCompletion(O3Class &o3class, O3Aggregate &agg)
HashTable< std::string, O3Class *> __classMap
This is a decoration of the DiscreteVariable class.
Definition: PRMType.h:63
bool __checkLabelsNumber(const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
Builds gum::prm::Class from gum::prm::o3prm::O3Class.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool __checkRuleCPTSumsTo1(const PRMClass< GUM_SCALAR > &c, const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
The O3RawCPT is part of the AST of the O3PRM language.
Definition: O3prm.h:510
std::vector< O3Class *> __o3Classes
bool __checkSlotChainLink(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain, const std::string &s)
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
Definition: PRM.h:66
<agrum/PRM/classElementContainer.h>
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
Definition: PRMClass.h:66
O3NameSolver< GUM_SCALAR > * __solver
O3ClassFactory< GUM_SCALAR > & operator=(const O3ClassFactory< GUM_SCALAR > &src)
void __addParameters(PRMFactory< GUM_SCALAR > &factory, O3Class &c)
const PRMClassElement< GUM_SCALAR > * __resolveSlotChain(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain)
bool __checkParametersNumber(O3Aggregate &agg, Size n)
The O3PRM is part of the AST of the O3PRM language.
Definition: O3prm.h:892
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
const PRMType * __checkAggParents(O3Class &o3class, O3Aggregate &agg)
Base class for dag.
Definition: DAG.h:102
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.