aGrUM  0.14.2
PRMInterface.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_INTERFACE_H
28 #define GUM_INTERFACE_H
29 
30 #include <set>
31 #include <utility>
32 #include <string>
33 
34 #include <agrum/agrum.h>
35 #include <agrum/core/sequence.h>
36 #include <agrum/core/set.h>
37 
43 
44 
45 namespace gum {
46  namespace prm {
47 
48  template < typename GUM_SCALAR >
49  class PRMClass;
50 
63  template < typename GUM_SCALAR >
64  class PRMInterface : public PRMClassElementContainer< GUM_SCALAR > {
65  // ========================================================================
66  friend class PRMClass< GUM_SCALAR >;
67  // ========================================================================
68  public:
69  // ========================================================================
71  // ========================================================================
73 
78  explicit PRMInterface(const std::string& name);
79 
86  PRMInterface(const std::string& name,
88  bool delayInheritance = false);
89 
92 
94  virtual ~PRMInterface();
95 
97  // ========================================================================
99  // ========================================================================
101 
103  virtual typename PRMObject::prm_type obj_type() const;
104 
106  virtual PRMClassElement< GUM_SCALAR >& get(NodeId id);
107 
109  virtual const PRMClassElement< GUM_SCALAR >& get(NodeId id) const;
110 
120  void addArc(const std::string& tail, const std::string& head);
121 
123  // ========================================================================
125  // ========================================================================
127 
128  virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR >& elt) const;
129 
132  virtual PRMClassElement< GUM_SCALAR >& get(const std::string& name);
133 
136  virtual const PRMClassElement< GUM_SCALAR >&
137  get(const std::string& name) const;
138 
145 
151 
155 
187 
189  // ========================================================================
191  // ========================================================================
193 
219  virtual bool
221 
228 
234  const PRMInterface< GUM_SCALAR >& super() const;
235 
240 
245 
250  void inheritInterface();
251 
253  // ========================================================================
255  // ========================================================================
257 
261 
265 
268  PRMClassElement< GUM_SCALAR >& operator[](const std::string& name);
269 
273  operator[](const std::string& name) const;
274 
276  // ========================================================================
278  // ========================================================================
280 
281  typedef typename NodeProperty< PRMClassElement< GUM_SCALAR >* >::iterator
284  const ClassEltIterator& end();
285 
286  typedef
287  typename NodeProperty< PRMClassElement< GUM_SCALAR >* >::const_iterator
290  const const_ClassEltIterator& end() const;
291 
293  protected:
295  const DAG& _dag() const;
296 
298  DAG& _dag();
299 
304 
308 
309  private:
312  operator=(const PRMInterface< GUM_SCALAR >& source);
313 
316 
317  // ========================================================================
319  // ========================================================================
321 
325 
329 
331  // ========================================================================
333  // ========================================================================
335 
339 
342 
345 
347  // ========================================================================
349  // ========================================================================
351 
357 
360 
365 
368 
373 
374  bool
376  const PRMClassElement< GUM_SCALAR >* overloader);
377 
379  PRMAttribute< GUM_SCALAR >* overloaded);
380 
382  PRMReferenceSlot< GUM_SCALAR >* overloaded);
383 
386 
388  };
389 
390 
391 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
392  extern template class PRMInterface< double >;
393 #endif
394 
395 
396  } /* namespace prm */
397 } // namespace gum
398 
400 
401 #endif /* GUM_INTERFACE_H */
NodeProperty< PRMClassElement< GUM_SCALAR > *>::iterator ClassEltIterator
Definition: PRMInterface.h:282
virtual PRMObject::prm_type obj_type() const
Implementation of pure virtual method of PRMObject.
const Set< PRMAttribute< GUM_SCALAR > *> & attributes() const
Returns the set of PRMAttribute<GUM_SCALAR> of this Class<GUM_SCALAR>.
virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const
Test if this PRMInterface is a sub PRMInterface of cec.
Unsafe Const Iterators for hashtablesHashTableConstIterator provides a fast but unsafe way to parse H...
Definition: hashTable.h:2462
Set< PRMClass< GUM_SCALAR > *> & implementations()
Returns the set of Class<GUM_SCALAR> implementing this PRMInterface.
Header file of gum::Sequence, a class for storing (ordered) sequences of objects. ...
void __addCastDescendants(PRMAttribute< GUM_SCALAR > *start, PRMAttribute< GUM_SCALAR > *end)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
ClassEltIterator begin()
Sets of elements (i.e.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
NodeId add(PRMClassElement< GUM_SCALAR > *elt)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::add(PRMClassElement<GUM_SCALAR>*).
Set< PRMClass< GUM_SCALAR > *> __implementations
The set of Class<GUM_SCALAR> which implements this PRMInterface.
Definition: PRMInterface.h:359
const DAG & _dag() const
Returns a constant reference over this PRMInterface&#39;s DAG.
Unsafe Iterators for hashtablesHashTableIterator provides a fast but unsafe way to parse HashTables...
Definition: hashTable.h:2747
NodeId overload(PRMClassElement< GUM_SCALAR > *elt)
Add a new PRMClassElement<GUM_SCALAR> which overload an inherited PRMClassElement<GUM_SCALAR>.
Abstract class representing an element of PRM class.
void _findAllSubtypes(Set< PRMClassElementContainer< GUM_SCALAR > * > &set)
Fills set with all the subtypes of this PRMInterface, this includes extensions and implementations...
void _updateDescendants(const PRMClassElement< GUM_SCALAR > &elt)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>(const PRMClassElement<GUM_SCALAR>&).
virtual ~PRMInterface()
Destructor.
Set< PRMInterface< GUM_SCALAR > *> __extensions
The set of Class<GUM_SCALAR> which implements this PRMInterface.
Definition: PRMInterface.h:367
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
A PRMReferenceSlot represent a relation between two PRMClassElementContainer.
Definition: PRMObject.h:220
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMInterface.h:324
The class for generic Hash Tables.
Definition: hashTable.h:676
Inline implementation of gum::prm::PRMInterface.
void __inheritInterface(const PRMInterface< GUM_SCALAR > &i)
Proceed with the copy of i in this.
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:66
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: PRMInterface.h:338
void __addExtension(PRMInterface< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to the set of Class<GUM_SCALAR> which implements this PRMInterface.
virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR > &elt) const
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(const std::string&).
void addArc(const std::string &tail, const std::string &head)
An Interfance doesn&#39;t have any arc, this will raise an OperationNotAllowed exception.
void __overloadAttribute(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
PRMInterface(const std::string &name)
Default constructor.
const Set< PRMReferenceSlot< GUM_SCALAR > *> & referenceSlots() const
Returns the set of PRMAggregate of this Class<GUM_SCALAR>.
An PRMInterface is implemented by a Class<GUM_SCALAR> and defines a set of PRMReferenceSlot<GUM_SCALA...
Definition: PRMClass.h:51
void __overloadReferenceSlot(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
PRMInterface< GUM_SCALAR > & super()
Returns the superInterface of this PRMInterface.
void __addImplementation(PRMClass< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to the set of Class<GUM_SCALAR> which implements this PRMInterface.
Headers of gum::PRMClassElement.
PRMInterface< GUM_SCALAR > & operator=(const PRMInterface< GUM_SCALAR > &source)
Copy operator. Don&#39;t use it.
void inheritInterface()
Inherits from this interface super interface, this should only be done when this inteface inheritance...
Headers of gum::PRMAttribute.
<agrum/PRM/classElementContainer.h>
Set< PRMAttribute< GUM_SCALAR > *> __attributes
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMInterface.h:341
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
Definition: PRMClass.h:63
bool __checkOverloadLegality(const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
const ClassEltIterator & end()
PRMInterface< GUM_SCALAR > * __superInterface
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMInterface.h:356
Set< PRMReferenceSlot< GUM_SCALAR > *> __referenceSlots
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMInterface.h:344
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: PRMInterface.h:328
PRMAttribute is a member of a Class in a PRM.
Definition: PRMAttribute.h:58
Headers of gum::prm::PRMClassElementContainer.
Headers of gum::PRMClassElement.
Base class for dag.
Definition: DAG.h:99
Size NodeId
Type for node ids.
Definition: graphElements.h:97
PRMClassElement< GUM_SCALAR > & operator[](NodeId id)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId).
NodeProperty< PRMClassElement< GUM_SCALAR > *>::const_iterator const_ClassEltIterator
Definition: PRMInterface.h:288
Headers of gum::PRMScalarAttribute.