aGrUM  0.14.2
O3ClassFactory.h
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
29 #include <algorithm>
30 #include <memory>
31 #include <string>
32 
33 #include <agrum/PRM/PRM.h>
34 #include <agrum/PRM/PRMFactory.h>
36 #include <agrum/PRM/o3prm/O3prm.h>
37 #include <agrum/core/hashTable.h>
38 #include <agrum/core/set.h>
39 
40 #ifndef GUM_PRM_O3PRM_O3CLASS_FACTORY_H
41 # define GUM_PRM_O3PRM_O3CLASS_FACTORY_H
42 
43 namespace gum {
44  namespace prm {
45  namespace o3prm {
46 
56  template < typename GUM_SCALAR >
58  public:
60  O3PRM& o3_prm,
62  ErrorsContainer& errors);
70 
71  void buildClasses();
72 
73  void buildImplementations();
74 
75  void buildParameters();
76 
77  void buildReferenceSlots();
78 
79  void declareAggregates();
80 
81  void completeAggregates();
82 
83  void declareAttributes();
84 
85  void completeAttributes();
86 
87 
88  private:
93 
98  std::vector< O3Class* > __o3Classes;
99 
103 
105 
106  bool __checkAndAddArcsToDag();
107 
108  bool __checkO3Classes();
110 
114 
116  O3Class& c,
117  O3Label& i,
121 
122  bool __checkImplementation(O3Label& o3_type, const PRMType& type);
123 
125  O3Label& o3_type, const PRMClassElementContainer< GUM_SCALAR >& type);
127 
131 
133 
136  void __addReferenceSlots(O3Class& c);
137 
138 
141 
144  void __declareAttribute(O3Class& c);
145 
147 
149 
150  bool __checkAttributeForCompletion(const O3Class& o3_c, O3Attribute& attr);
151 
152  bool __checkParent(const PRMClass< GUM_SCALAR >& c, const O3Label& prnt);
153 
155  const O3Label& prnt);
156 
158  const O3Label& prnt);
159 
160  bool __checkRawCPT(const PRMClass< GUM_SCALAR >& c, O3RawCPT& attr);
161 
162  bool __checkRuleCPT(const PRMClass< GUM_SCALAR >& c, O3RuleCPT& attr);
163 
164  bool __checkLabelsNumber(const O3RuleCPT& attr,
165  const O3RuleCPT::O3Rule& rule);
166 
168  const O3RuleCPT& attr,
169  const O3RuleCPT::O3Rule& rule);
170 
171  void __addParamsToForms(
172  const HashTable< std::string, const PRMParameter< GUM_SCALAR >* >&
173  scope,
174  O3RuleCPT::O3Rule& rule);
175 
177  const O3RuleCPT& attr,
178  const O3RuleCPT::O3Rule& rule);
179 
181 
186  const O3Label& chain);
187 
189  const O3Label& chain,
190  const std::string& s);
192 
195  void __declareAggregates(O3Class& c);
197 
200 
201  const PRMType* __checkAggParents(O3Class& o3class, O3Aggregate& agg);
202 
203  bool __checkAggTypeLegality(O3Class& o3class, O3Aggregate& agg);
204 
205 
206  bool __checkAggParameters(O3Class& o3class,
207  O3Aggregate& agg,
208  const PRMType* t);
209 
211 
213 
214  // @}
215  };
216 
217  } // namespace o3prm
218  } // namespace prm
219 } // namespace gum
220 
221 // always include the implementation of the templates
223 
224 
225 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
226 extern template class gum::prm::o3prm::O3ClassFactory< double >;
227 # endif
228 
229 
230 #endif // GUM_PRM_O3PRM_O3CLASS_FACTORY_H
std::pair< O3LabelList, O3FormulaList > O3Rule
Definition: O3prm.h:544
bool __checkAggregateForDeclaration(O3Class &o3class, O3Aggregate &agg)
PRMParameter is a member of a Class in a PRM.
Definition: PRMParameter.h:49
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)
Sets of elements (i.e.
bool __checkAttributeForDeclaration(O3Class &o3_c, O3Attribute &attr)
bool __checkRawCPT(const PRMClass< GUM_SCALAR > &c, O3RawCPT &attr)
Implementation for the O3ClassFactory class.
The O3Aggregate is part of the AST of the O3PRM language.
Definition: O3prm.h:575
bool __checkReferenceSlot(O3Class &c, O3ReferenceSlot &ref)
Abstract class representing an element of PRM class.
Headers of PRM.
Headers for the O3NameSolver class.
This class is used contain and manipulate gum::ParseError.
The O3Label is part of the AST of the O3PRM language.
Definition: O3prm.h:171
bool __checkParent(const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
The O3Attribute is part of the AST of the O3PRM language.
Definition: O3prm.h:469
void __completeAggregates(PRMFactory< GUM_SCALAR > &factory, O3Class &c)
gum is the global namespace for all aGrUM entities
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:540
Resolves names for the different O3PRM factories.
Definition: O3NameSolver.h:55
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:617
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:47
The O3ReferenceSlot is part of the AST of the O3PRM language.
Definition: O3prm.h:436
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:60
bool __checkLabelsNumber(const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
Builds gum::prm::Class from gum::prm::o3prm::O3Class.
Headers for the AST of the O3PRM language.
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:508
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:63
<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:63
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:890
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
const PRMType * __checkAggParents(O3Class &o3class, O3Aggregate &agg)
Base class for dag.
Definition: DAG.h:99
Class hash tables iterators.
Headers of PRMFactory.