aGrUM  0.14.2
PRMClass.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
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  ***************************************************************************/
27 #ifndef GUM_CLASS_H
28 #define GUM_CLASS_H
29 
30 #include <utility>
31 
32 #include <agrum/agrum.h>
33 #include <agrum/core/hashFunc.h>
34 #include <agrum/core/bijection.h>
35 #include <agrum/core/sequence.h>
36 #include <agrum/core/set.h>
45 
46 
47 namespace gum {
48  namespace prm {
49 
50  template < typename GUM_SCALAR >
51  class PRMInterface;
52 
62  template < typename GUM_SCALAR >
63  class PRMClass : public PRMClassElementContainer< GUM_SCALAR > {
64  friend class PRMInterface< GUM_SCALAR >;
65 
66  public:
69 
74  explicit PRMClass(const std::string& name);
75 
82  PRMClass(const std::string& name,
84  bool delayInheritance = false);
85 
94  PRMClass(const std::string& name,
95  const Set< PRMInterface< GUM_SCALAR >* >& set,
96  bool delayInheritance = false);
97 
106  PRMClass(const std::string& name,
108  const Set< PRMInterface< GUM_SCALAR >* >& set,
109  bool delayInheritance = false);
110 
112  PRMClass(const PRMClass< GUM_SCALAR >& source) = delete;
113 
115  PRMClass(const PRMClass< GUM_SCALAR >&& source) = delete;
116 
119  operator=(const PRMClass< GUM_SCALAR >& source) = delete;
120 
123  operator=(const PRMClass< GUM_SCALAR >&& source) = delete;
124 
126  virtual ~PRMClass();
127 
129  virtual PRMObject::prm_type obj_type() const;
131  // ========================================================================
133  // ========================================================================
135 
138 
140  const PRMClassElement< GUM_SCALAR >& get(NodeId id) const;
141 
143  // ========================================================================
145  // ========================================================================
147 
153  virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR >& elt) const;
154 
167  bool isCastDescendant(const std::string& safe_name) const;
168 
171  PRMClassElement< GUM_SCALAR >& get(const std::string& name);
172 
175  const PRMClassElement< GUM_SCALAR >& get(const std::string& name) const;
176 
179 
182 
184  virtual void addArc(const std::string& tail, const std::string& head);
185 
192 
198 
204 
211 
219 
226 
228  // ========================================================================
230  // ========================================================================
232 
253  virtual bool
255 
261  const PRMClass< GUM_SCALAR >& super() const;
262 
272 
275  const Set< PRMClass< GUM_SCALAR >* >& extensions() const;
276 
278  // ========================================================================
280  // ========================================================================
282 
286 
290 
293  PRMClassElement< GUM_SCALAR >& operator[](const std::string& name);
294 
298  operator[](const std::string& name) const;
299 
301 
304  void inheritReferenceSlots();
305  void inheritParameters();
306  void inheritAttributes();
307  void inheritAggregates();
308  void inheritSlotChains();
309  void initializeInheritance();
310  void completeInheritance(const std::string& attr);
312 
313  protected:
315  virtual const DAG& _dag() const;
316 
319  virtual DAG& _dag();
320 
323 
327 
328  private:
330  // void __copyClass<GUM_SCALAR>(const Class<GUM_SCALAR>& c);
331 
332  // ========================================================================
334  // ========================================================================
336 
340 
344 
346  // ========================================================================
348  // ========================================================================
350 
354 
357 
360 
363 
366 
369 
372 
377 
379  // ========================================================================
381  // ========================================================================
383 
389 
392 
396 
401 
404 
405 
407  void __inheritClass(const PRMClass< GUM_SCALAR >& c);
408 
410  void __implementInterfaces(bool delayInheritance);
411 
414 
418 
421 
425 
429 
439 
441  bool
443  const PRMClassElement< GUM_SCALAR >* overloader);
444 
447  PRMAttribute< GUM_SCALAR >* overloaded);
448 
451  PRMClassElement< GUM_SCALAR >* overloaded);
452 
455  PRMReferenceSlot< GUM_SCALAR >* overloaded);
456 
459  PRMParameter< GUM_SCALAR >* overloaded);
460 
462  };
463 
464 
465 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
466  extern template class PRMClass< double >;
467 #endif
468 
469 
470  } /* namespace prm */
471 
472 } // namespace gum
473 
475 
476 
477 namespace gum {
478 
479  namespace prm {} /* namespace prm */
480 
481 } // namespace gum
482 
483 
484 #endif /* GUM_CLASS_H */
void __checkInterfaces(PRMClassElement< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:526
virtual NodeId add(PRMClassElement< GUM_SCALAR > *elt)
See gum::prm::add(PRMClassElement<GUM_SCALAR>*).
Definition: PRMClass_tpl.h:618
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:49
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:388
Headers of gum::PRMSlotChain.
Header file of gum::Sequence, a class for storing (ordered) sequences of objects. ...
Headers of gum::PRMParameter.
void __overloadAttribute(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
Overloads an attribute.
Definition: PRMClass_tpl.h:804
Sets of elements (i.e.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
HashFunc< PRMClassElementContainer< GUM_SCALAR > *> __dummy_hashfunc
a dummy member used to fix a compilation issue in clang4
Definition: PRMClass.h:403
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.
Headers of MultiDimSparse.
Inline implementation of gum::Class.
void completeInheritance(const std::string &attr)
Definition: PRMClass_tpl.h:289
Abstract class representing an element of PRM class.
Set< PRMReferenceSlot< GUM_SCALAR > *> __referenceSlots
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:359
Classes providing basic hash functions for hash tables.
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:343
Class template representing hashing function of LpCol.
Definition: hashFunc.h:469
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:362
void __checkRefInterfaces(PRMReferenceSlot< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:581
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Headers of gum::MultiDimImplementation.
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:220
void __overloadAggregate(PRMAggregate< GUM_SCALAR > *overloader, PRMClassElement< GUM_SCALAR > *overloaded)
Overloads an aggregate.
The class for generic Hash Tables.
Definition: hashTable.h:676
void _findAllSubtypes(Set< PRMClassElementContainer< GUM_SCALAR > * > &set)
Fills set with all the subtypes of this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:965
Set< PRMSlotChain< GUM_SCALAR > *> __slotChains
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:365
Set< PRMInterface< GUM_SCALAR > *> * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:391
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
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:400
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:66
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:339
void initializeInheritance()
Definition: PRMClass_tpl.h:130
void __checkRefInterface(PRMReferenceSlot< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
Check that a given element respects a specific interface.
Definition: PRMClass_tpl.h:593
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:99
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:37
virtual void addArc(const std::string &tail, const std::string &head)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::addArc().
Definition: PRMClass_tpl.h:480
virtual NodeId overload(PRMClassElement< GUM_SCALAR > *elt)
See gum::prm::overload(PRMClassElement<GUM_SCALAR>*).
Definition: PRMClass_tpl.h:730
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1803
virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const
Test if this Class<GUM_SCALAR> is a subclass of cec.
Definition: PRMClass_tpl.h:442
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:51
void __inheritClass(const PRMClass< GUM_SCALAR > &c)
Proceed with the copy when this inherits c.
Definition: PRMClass_tpl.h:312
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:395
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:927
Headers of gum::PRMAggregate.
Headers of gum::PRMAttribute.
<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:63
void inheritReferenceSlots()
Definition: PRMClass_tpl.h:149
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:539
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>&).
Definition: PRMClass_tpl.h:999
virtual ~PRMClass()
Destructor.
Definition: PRMClass_tpl.h:117
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:974
void __overloadReference(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
Overloads a reference slot.
Definition: PRMClass_tpl.h:831
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:356
PRMAttribute is a member of a Class in a PRM.
Definition: PRMAttribute.h:58
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:353
Headers of gum::prm::PRMClassElementContainer.
const Set< PRMReferenceSlot< GUM_SCALAR > *> & referenceSlots() const
Returns the set of PRMReferenceSlot<GUM_SCALAR> of this Class<GUM_SCALAR>.
Headers of gum::PRMClassElement.
Base class for dag.
Definition: DAG.h:99
Size NodeId
Type for node ids.
Definition: graphElements.h:97
Set of pairs of elements with fast search for both elements.
void __addCastDescendants(PRMClassElement< GUM_SCALAR > *attr)
Recursively adds cast descendant of attr in this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:692
Set< PRMParameter< GUM_SCALAR > *> __parameters
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:368