aGrUM  0.14.2
PRMClassElementContainer.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_ELEMENT_CONTAINER_H
28 #define GUM_CLASS_ELEMENT_CONTAINER_H
29 
30 #include <agrum/core/hashTable.h>
31 #include <agrum/core/set.h>
32 
33 #include <agrum/graphs/DAG.h>
35 
36 #include <agrum/PRM/utils_prm.h>
37 
39 
40 namespace gum {
41  namespace prm {
42 
43  template < typename GUM_SCALAR >
44  class PRMClass;
45  template < typename GUM_SCALAR >
46  class PRMInterface;
47  class PRMClassElementContainterIterator;
48  class PRMClassElementContainterConstIterator;
49 
63  template < typename GUM_SCALAR >
67 
68  public:
69  // ========================================================================
71  // ========================================================================
73 
75  PRMClassElementContainer(const std::string& name);
76 
78  virtual ~PRMClassElementContainer();
79 
81  // ========================================================================
83  // ========================================================================
85 
91  virtual bool belongsTo(const PRMClassElement< GUM_SCALAR >& elt) const;
92 
98  virtual bool exists(const std::string& name) const;
99 
106  virtual PRMClassElement< GUM_SCALAR >& get(const std::string& name) = 0;
107 
114  virtual const PRMClassElement< GUM_SCALAR >&
115  get(const std::string& name) const = 0;
116 
141  virtual NodeId add(PRMClassElement< GUM_SCALAR >* elt) = 0;
142 
178 
182  virtual void addArc(const std::string& tail, const std::string& head) = 0;
183 
195  virtual bool isInputNode(const PRMClassElement< GUM_SCALAR >& elt) const;
196 
216  virtual void setInputNode(const PRMClassElement< GUM_SCALAR >& elt, bool b);
217 
229  virtual bool
230  isOutputNode(const PRMClassElement< GUM_SCALAR >& elt) const = 0;
231 
251  virtual void setOutputNode(const PRMClassElement< GUM_SCALAR >& elt, bool b);
252 
271  virtual bool isInnerNode(const PRMClassElement< GUM_SCALAR >& elt) const;
273  // ========================================================================
275  // ========================================================================
277 
290  virtual const DAG& containerDag() const;
291 
299  virtual bool exists(NodeId id) const;
300 
307  virtual PRMClassElement< GUM_SCALAR >& get(NodeId id) = 0;
308 
315  virtual const PRMClassElement< GUM_SCALAR >& get(NodeId id) const = 0;
316 
318  // ========================================================================
320  // ========================================================================
322 
330 
337  virtual const PRMClassElement< GUM_SCALAR >& operator[](NodeId id) const = 0;
338 
346  operator[](const std::string& name) = 0;
347 
354  virtual const PRMClassElement< GUM_SCALAR >&
355  operator[](const std::string& name) const = 0;
356 
358  // ========================================================================
360  // ========================================================================
362 
370  virtual bool
372 
382  virtual bool
384 
386 
387  protected:
391 
395 
396  virtual const DAG& _dag() const = 0;
397 
400  virtual DAG& _dag() = 0;
401 
405  virtual void
407 
412  virtual std::pair< bool, bool >&
414 
419  virtual const std::pair< bool, bool >&
420  _getIOFlag(const PRMClassElement< GUM_SCALAR >& elt) const;
421 
427  virtual void _setIOFlag(const PRMClassElement< GUM_SCALAR >& elt,
428  const std::pair< bool, bool >& flags);
429 
433 
441  virtual void
443 
444  private:
447  };
448 
449 
450 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
451  extern template class PRMClassElementContainer< double >;
452 #endif
453 
454 
455  } /* namespace prm */
456 
457 } // namespace gum
458 
461 template < typename GUM_SCALAR >
462 std::ostream&
463  operator<<(std::ostream& output,
465 
467 
468 #endif /* GUM_CLASS_ELEMENT_CONTAINER_H */
PRMClassElementContainer< GUM_SCALAR > & operator=(const PRMClassElementContainer< GUM_SCALAR > &source)
Copy operator. Don&#39;t use it.
Inline implementation of gum::PRMClassElementContainer.
std::ostream & operator<<(std::ostream &out, PRMObject::prm_type obj_type)
For printing PRMType easily.
Definition: PRMObject.cpp:75
PRMClassElementContainer(const std::string &name)
Default constructor.
Sets of elements (i.e.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
virtual PRMClassElement< GUM_SCALAR > & operator[](NodeId id)=0
Getter on a member of this PRMClassElementContainer.
virtual bool isInnerNode(const PRMClassElement< GUM_SCALAR > &elt) const
Returns true if the node is an inner node.
virtual void setInputNode(const PRMClassElement< GUM_SCALAR > &elt, bool b)
Set the input flag value of id at b.
Abstract class representing an element of PRM class.
virtual bool exists(const std::string &name) const
Returns true if a member with the given name exists in this PRMClassElementContainer or in the PRMCla...
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:676
virtual void _copyIOFlags(const PRMClassElementContainer< GUM_SCALAR > &c)
Copy the IO Flags of c in this PRMClassElementContainer.
virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const =0
Test if this PRMClassElementContainer is a subtype of cec.
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
HashTable< std::string, std::pair< bool, bool > > __IOFlags
input / output flags, useful when inheriting or copying.
virtual const DAG & _dag() const =0
virtual bool belongsTo(const PRMClassElement< GUM_SCALAR > &elt) const
Returns true if elt belongs to this PRMClassElementContainer.
virtual std::pair< bool, bool > & _getIOFlag(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
virtual bool isInputNode(const PRMClassElement< GUM_SCALAR > &elt) const
Returns true if the node is an input node.
virtual void _findAllSubtypes(Set< PRMClassElementContainer< GUM_SCALAR > * > &set)=0
Fills set with all the subtypes of this PRMInterface, this includes extensions and implementations...
virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR > &elt) const =0
Returns true if the node is an output node.
virtual bool isSuperTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const
Test if this PRMClassElementContainer is a super type of cec.
virtual NodeId add(PRMClassElement< GUM_SCALAR > *elt)=0
Add a PRMClassElement<GUM_SCALAR> to this PRMClassElementContainer.
Abstract base class for any element defined in a PRM.
Definition: PRMObject.h:53
virtual NodeId overload(PRMClassElement< GUM_SCALAR > *elt)=0
Add a PRMClassElement<GUM_SCALAR> which overload an inherited PRMClassElement<GUM_SCALAR>.
virtual void setOutputNode(const PRMClassElement< GUM_SCALAR > &elt, bool b)
Set the output flag value of id at b.
<agrum/PRM/classElementContainer.h>
virtual void _setIOFlag(const PRMClassElement< GUM_SCALAR > &elt, const std::pair< bool, bool > &flags)
Defines the IO flags of a PRMClassElement<GUM_SCALAR>.
virtual void _updateDescendants(const PRMClassElement< GUM_SCALAR > &elt)=0
When a PRMClassElement<GUM_SCALAR> becomes an Output node we must update any the IO flags of every de...
virtual void addArc(const std::string &tail, const std::string &head)=0
Add an arc between two PRMClassElement<GUM_SCALAR>.
virtual const DAG & containerDag() const
Returns the gum::DAG of this PRMClassElementContainer.
Base class for dag.
Definition: DAG.h:99
Class hash tables iterators.
Headers of PRMObject.
Size NodeId
Type for node ids.
Definition: graphElements.h:97
Base classes for directed acyclic graphs.
some utils for topology : NodeId, Edge, Arc and consorts ...