aGrUM  0.16.0
PRMClass.h
Go to the documentation of this file.
1 
30 #ifndef GUM_CLASS_H
31 #define GUM_CLASS_H
32 
33 #include <utility>
34 
35 #include <agrum/agrum.h>
36 #include <agrum/core/hashFunc.h>
37 #include <agrum/core/bijection.h>
38 #include <agrum/core/sequence.h>
39 #include <agrum/core/set.h>
48 
49 
50 namespace gum {
51  namespace prm {
52 
53  template < typename GUM_SCALAR >
54  class PRMInterface;
55 
65  template < typename GUM_SCALAR >
66  class PRMClass : public PRMClassElementContainer< GUM_SCALAR > {
67  friend class PRMInterface< GUM_SCALAR >;
68 
69  public:
72 
77  explicit PRMClass(const std::string& name);
78 
85  PRMClass(const std::string& name,
87  bool delayInheritance = false);
88 
97  PRMClass(const std::string& name,
98  const Set< PRMInterface< GUM_SCALAR >* >& set,
99  bool delayInheritance = false);
100 
109  PRMClass(const std::string& name,
111  const Set< PRMInterface< GUM_SCALAR >* >& set,
112  bool delayInheritance = false);
113 
115  PRMClass(const PRMClass< GUM_SCALAR >& source) = delete;
116 
118  PRMClass(const PRMClass< GUM_SCALAR >&& source) = delete;
119 
122  operator=(const PRMClass< GUM_SCALAR >& source) = delete;
123 
126  operator=(const PRMClass< GUM_SCALAR >&& source) = delete;
127 
129  virtual ~PRMClass();
130 
132  virtual PRMObject::prm_type obj_type() const;
134  // ========================================================================
136  // ========================================================================
138 
141 
143  const PRMClassElement< GUM_SCALAR >& get(NodeId id) const;
144 
146  // ========================================================================
148  // ========================================================================
150 
156  virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR >& elt) const;
157 
170  bool isCastDescendant(const std::string& safe_name) const;
171 
174  PRMClassElement< GUM_SCALAR >& get(const std::string& name);
175 
178  const PRMClassElement< GUM_SCALAR >& get(const std::string& name) const;
179 
182 
185 
187  virtual void addArc(const std::string& tail, const std::string& head);
188 
195 
201 
207 
214 
222 
229 
231  // ========================================================================
233  // ========================================================================
235 
256  virtual bool
258 
264  const PRMClass< GUM_SCALAR >& super() const;
265 
275 
278  const Set< PRMClass< GUM_SCALAR >* >& extensions() const;
279 
281  // ========================================================================
283  // ========================================================================
285 
289 
293 
296  PRMClassElement< GUM_SCALAR >& operator[](const std::string& name);
297 
301  operator[](const std::string& name) const;
302 
304 
307  void inheritReferenceSlots();
308  void inheritParameters();
309  void inheritAttributes();
310  void inheritAggregates();
311  void inheritSlotChains();
312  void initializeInheritance();
313  void completeInheritance(const std::string& attr);
315 
316  protected:
318  virtual const DAG& _dag() const;
319 
322  virtual DAG& _dag();
323 
326 
330 
331  private:
333  // void __copyClass<GUM_SCALAR>(const Class<GUM_SCALAR>& c);
334 
335  // ========================================================================
337  // ========================================================================
339 
343 
347 
349  // ========================================================================
351  // ========================================================================
353 
357 
360 
363 
366 
369 
372 
375 
380 
382  // ========================================================================
384  // ========================================================================
386 
392 
395 
399 
404 
407 
408 
410  void __inheritClass(const PRMClass< GUM_SCALAR >& c);
411 
413  void __implementInterfaces(bool delayInheritance);
414 
417 
421 
424 
428 
432 
442 
444  bool
446  const PRMClassElement< GUM_SCALAR >* overloader);
447 
450  PRMAttribute< GUM_SCALAR >* overloaded);
451 
454  PRMClassElement< GUM_SCALAR >* overloaded);
455 
458  PRMReferenceSlot< GUM_SCALAR >* overloaded);
459 
462  PRMParameter< GUM_SCALAR >* overloaded);
463 
465  };
466 
467 
468 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
469  extern template class PRMClass< double >;
470 #endif
471 
472 
473  } /* namespace prm */
474 
475 } // namespace gum
476 
478 
479 
480 namespace gum {
481 
482  namespace prm {} /* namespace prm */
483 
484 } // namespace gum
485 
486 
487 #endif /* GUM_CLASS_H */
void __checkInterfaces(PRMClassElement< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:529
virtual NodeId add(PRMClassElement< GUM_SCALAR > *elt)
See gum::prm::add(PRMClassElement<GUM_SCALAR>*).
Definition: PRMClass_tpl.h:621
const Set< PRMInterface< GUM_SCALAR > *> & implements() const
Returns the Set of PRMInterface<GUM_SCALAR> implemented by this Class<GUM_SCALAR>.
PRMParameter is a member of a Class in a PRM.
Definition: PRMParameter.h:52
const Set< PRMAttribute< GUM_SCALAR > *> & attributes() const
Returns the set of PRMAttribute<GUM_SCALAR> of this Class<GUM_SCALAR>.
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:391
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __overloadAttribute(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
Overloads an attribute.
Definition: PRMClass_tpl.h:807
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
HashFunc< PRMClassElementContainer< GUM_SCALAR > *> __dummy_hashfunc
a dummy member used to fix a compilation issue in clang4
Definition: PRMClass.h:406
bool __checkOverloadLegality(const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
Return true of overloaded can be overload by overloader.
const Set< PRMSlotChain< GUM_SCALAR > *> & slotChains() const
Returns the set of PRMSlotChain<GUM_SCALAR> of this Class<GUM_SCALAR>.
PRMClassElement< GUM_SCALAR > & operator[](NodeId id)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId).
bool isCastDescendant(const std::string &safe_name) const
Return true if the attribute named safe_name is a cast descendant.
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.
void completeInheritance(const std::string &attr)
Definition: PRMClass_tpl.h:292
Abstract class representing an element of PRM class.
Set< PRMReferenceSlot< GUM_SCALAR > *> __referenceSlots
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:362
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
NodeProperty< PRMClassElement< GUM_SCALAR > *> __nodeIdMap
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:346
Class template representing hashing function of LpCol.
Definition: hashFunc.h:471
const Set< PRMClass< GUM_SCALAR > *> & extensions() const
Returns the set of Class<GUM_SCALAR> which are direct sub-Class<GUM_SCALAR> of this Class<GUM_SCALAR>...
Set< PRMAggregate< GUM_SCALAR > *> __aggregates
The sequence of aggregate.
Definition: PRMClass.h:365
void __checkRefInterfaces(PRMReferenceSlot< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:584
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const Set< PRMAggregate< GUM_SCALAR > *> & aggregates() const
Returns the set of PRMAggregate<GUM_SCALAR> of this Class<GUM_SCALAR>.
A PRMReferenceSlot represent a relation between two PRMClassElementContainer.
Definition: PRMObject.h:223
void __overloadAggregate(PRMAggregate< GUM_SCALAR > *overloader, PRMClassElement< GUM_SCALAR > *overloaded)
Overloads an aggregate.
The class for generic Hash Tables.
Definition: hashTable.h:679
void _findAllSubtypes(Set< PRMClassElementContainer< GUM_SCALAR > * > &set)
Fills set with all the subtypes of this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:968
Set< PRMSlotChain< GUM_SCALAR > *> __slotChains
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:368
Set< PRMInterface< GUM_SCALAR > *> * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:394
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
Bijection< const DiscreteVariable *, const DiscreteVariable *> * __bijection
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:403
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:69
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342
void initializeInheritance()
Definition: PRMClass_tpl.h:133
void __checkRefInterface(PRMReferenceSlot< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
Check that a given element respects a specific interface.
Definition: PRMClass_tpl.h:596
HashTable< std::string, const PRMParameter< GUM_SCALAR > *> scope() const
Returns all the parameters in the scope of this class.
void __implementInterfaces(bool delayInheritance)
Proceed with the implementation of interfaces.
Definition: PRMClass_tpl.h:102
const Set< PRMParameter< GUM_SCALAR > *> & parameters() const
Returns the set of parameters of this Class<GUM_SCALAR>.
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:40
virtual void addArc(const std::string &tail, const std::string &head)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::addArc().
Definition: PRMClass_tpl.h:483
virtual NodeId overload(PRMClassElement< GUM_SCALAR > *elt)
See gum::prm::overload(PRMClassElement<GUM_SCALAR>*).
Definition: PRMClass_tpl.h:733
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const
Test if this Class<GUM_SCALAR> is a subclass of cec.
Definition: PRMClass_tpl.h:445
virtual PRMObject::prm_type obj_type() const
Implementation of pure virtual method of PRMObject.
An PRMInterface is implemented by a Class<GUM_SCALAR> and defines a set of PRMReferenceSlot<GUM_SCALA...
Definition: PRMClass.h:54
void __inheritClass(const PRMClass< GUM_SCALAR > &c)
Proceed with the copy when this inherits c.
Definition: PRMClass_tpl.h:315
Set< PRMClass< GUM_SCALAR > *> __extensions
The set of Class<GUM_SCALAR> which are extension of this Class<GUM_SCALAR> (i.e. direct subtypes)...
Definition: PRMClass.h:398
virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR > &elt) const
Returns true if elt is an output node.
void __overloadParameter(PRMParameter< GUM_SCALAR > *overloader, PRMParameter< GUM_SCALAR > *overloaded)
Overloads a parameter.
Definition: PRMClass_tpl.h:930
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.
<agrum/PRM/classElementContainer.h>
virtual const DAG & _dag() const
returns a constant reference over this interface&#39;s dag.
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
Definition: PRMClass.h:66
void inheritReferenceSlots()
Definition: PRMClass_tpl.h:152
void __addExtension(PRMClass< GUM_SCALAR > *c)
This method is called when a sub-Class<GUM_SCALAR> of this Class<GUM_SCALAR> is created.
void __checkInterface(PRMClassElement< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
Check that a given element respects a specific interface.
Definition: PRMClass_tpl.h:542
PRMClass< GUM_SCALAR > & operator=(const PRMClass< GUM_SCALAR > &source)=delete
Copy operator. Don&#39;t use it.
void _updateDescendants(const PRMClassElement< GUM_SCALAR > &elt)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>(const PRMClassElement<GUM_SCALAR>&).
virtual ~PRMClass()
Destructor.
Definition: PRMClass_tpl.h:120
void __addIOInterfaceFlags(PRMClassElement< GUM_SCALAR > *elt)
Check if elt is present in an implementation. If it is, its IO flags are updated. ...
Definition: PRMClass_tpl.h:977
void __overloadReference(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
Overloads a reference slot.
Definition: PRMClass_tpl.h:834
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
Set< PRMAttribute< GUM_SCALAR > *> __attributes
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:359
PRMAttribute is a member of a Class in a PRM.
Definition: PRMAttribute.h:61
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> __nameMap
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:356
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const Set< PRMReferenceSlot< GUM_SCALAR > *> & referenceSlots() const
Returns the set of PRMReferenceSlot<GUM_SCALAR> of this Class<GUM_SCALAR>.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Base class for dag.
Definition: DAG.h:102
Size NodeId
Type for node ids.
Definition: graphElements.h:98
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __addCastDescendants(PRMClassElement< GUM_SCALAR > *attr)
Recursively adds cast descendant of attr in this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:695
Set< PRMParameter< GUM_SCALAR > *> __parameters
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:371