aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
PRMClassElementContainer.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
48
49#ifndef GUM_CLASS_ELEMENT_CONTAINER_H
50#define GUM_CLASS_ELEMENT_CONTAINER_H
51
52
53#include <agrum/PRM/utils_prm.h>
54
55namespace gum {
56 namespace prm {
57
58 template < typename GUM_SCALAR >
59 class PRMClass;
60 template < typename GUM_SCALAR >
61 class PRMInterface;
62 class PRMClassElementContainterIterator;
63 class PRMClassElementContainterConstIterator;
64
78 template < typename GUM_SCALAR >
82
83 public:
84 // ========================================================================
86 // ========================================================================
88
90 PRMClassElementContainer(const std::string& name);
91
94
96 // ========================================================================
98 // ========================================================================
100
106 virtual bool belongsTo(const PRMClassElement< GUM_SCALAR >& elt) const;
107
113 virtual bool exists(const std::string& name) const;
114
121 virtual PRMClassElement< GUM_SCALAR >& get(const std::string& name) = 0;
122
129 virtual const PRMClassElement< GUM_SCALAR >& get(const std::string& name) const = 0;
130
156
192
196 virtual void addArc(const std::string& tail, const std::string& head) = 0;
197
209 virtual bool isInputNode(const PRMClassElement< GUM_SCALAR >& elt) const;
210
230 virtual void setInputNode(const PRMClassElement< GUM_SCALAR >& elt, bool b);
231
243 virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR >& elt) const = 0;
244
264 virtual void setOutputNode(const PRMClassElement< GUM_SCALAR >& elt, bool b);
265
284 virtual bool isInnerNode(const PRMClassElement< GUM_SCALAR >& elt) const;
286 // ========================================================================
288 // ========================================================================
290
303 virtual const DAG& containerDag() const;
304
312 virtual bool exists(NodeId id) const;
313
321
328 virtual const PRMClassElement< GUM_SCALAR >& get(NodeId id) const = 0;
329
331 // ========================================================================
333 // ========================================================================
335
343
350 virtual const PRMClassElement< GUM_SCALAR >& operator[](NodeId id) const = 0;
351
358 virtual PRMClassElement< GUM_SCALAR >& operator[](const std::string& name) = 0;
359
366 virtual const PRMClassElement< GUM_SCALAR >& operator[](const std::string& name) const = 0;
367
369 // ========================================================================
371 // ========================================================================
373
381 virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR >& cec) const = 0;
382
392 virtual bool isSuperTypeOf(const PRMClassElementContainer< GUM_SCALAR >& cec) const;
393
395
396 protected:
400
403
404 virtual const DAG& dag_() const = 0;
405
408 virtual DAG& dag_() = 0;
409
414
419 virtual std::pair< bool, bool >& getIOFlag_(const PRMClassElement< GUM_SCALAR >& elt);
420
425 virtual const std::pair< bool, bool >&
427
433 virtual void setIOFlag_(const PRMClassElement< GUM_SCALAR >& elt,
434 const std::pair< bool, bool >& flags);
435
439
448
449 private:
452 };
453
454
455#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
456 extern template class PRMClassElementContainer< double >;
457#endif
458
459
460 } /* namespace prm */
461
462} // namespace gum
463
466template < typename GUM_SCALAR >
467std::ostream& operator<<(std::ostream& output,
469
471
472#endif /* GUM_CLASS_ELEMENT_CONTAINER_H */
std::ostream & operator<<(std::ostream &output, const gum::prm::PRMClassElementContainer< GUM_SCALAR > &container)
An << operator for PRMClassElementContainer. Output in the graphviz-dot format.
Inline implementation of gum::PRMClassElementContainer.
Base class for dag.
Definition DAG.h:121
The class for generic Hash Tables.
Definition hashTable.h:637
Representation of a set.
Definition set.h:131
virtual PRMClassElement< GUM_SCALAR > & get(NodeId id)=0
Getter on a member of this PRMClassElementContainer.
virtual NodeId overload(PRMClassElement< GUM_SCALAR > *elt)=0
Add a PRMClassElement<GUM_SCALAR> which overload an inherited PRMClassElement<GUM_SCALAR>.
virtual PRMClassElement< GUM_SCALAR > & get(const std::string &name)=0
Getter on a member of this PRMClassElementContainer.
virtual const PRMClassElement< GUM_SCALAR > & operator[](NodeId id) const =0
Constant 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 const DAG & containerDag() const
Returns the gum::DAG of this PRMClassElementContainer.
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
virtual void addArc(const std::string &tail, const std::string &head)=0
Add an arc between two PRMClassElement<GUM_SCALAR>.
virtual void copyIOFlags_(const PRMClassElementContainer< GUM_SCALAR > &c)
Copy the IO Flags of c in this PRMClassElementContainer.
PRMClassElementContainer< GUM_SCALAR > & operator=(const PRMClassElementContainer< GUM_SCALAR > &source)
Copy operator. Don't use it.
virtual void findAllSubtypes_(Set< PRMClassElementContainer< GUM_SCALAR > * > &set)=0
Fills set with all the subtypes of this PRMInterface, this includes extensions and implementations.
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 bool belongsTo(const PRMClassElement< GUM_SCALAR > &elt) const
Returns true if elt belongs to this PRMClassElementContainer.
virtual const PRMClassElement< GUM_SCALAR > & get(NodeId id) const =0
Constant getter on a member of this PRMClassElementContainer.
HashTable< std::string, std::pair< bool, bool > > _IOFlags_
input / output flags, useful when inheriting or copying.
virtual DAG & dag_()=0
Returns a non constant reference over this PRMClassElementContainer's DAG.
virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const =0
Test if this PRMClassElementContainer is a subtype of cec.
virtual PRMClassElement< GUM_SCALAR > & operator[](NodeId id)=0
Getter on a member of this PRMClassElementContainer.
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.
virtual void setIOFlag_(const PRMClassElement< GUM_SCALAR > &elt, const std::pair< bool, bool > &flags)
Defines the IO flags of a PRMClassElement<GUM_SCALAR>.
virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR > &elt) const =0
Returns true if the node is an output node.
PRMClassElementContainer(const std::string &name)
Default constructor.
virtual bool isInputNode(const PRMClassElement< GUM_SCALAR > &elt) const
Returns true if the node is an input node.
virtual const PRMClassElement< GUM_SCALAR > & operator[](const std::string &name) const =0
Constant getter on a member of this PRMClassElementContainer.
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...
virtual PRMClassElement< GUM_SCALAR > & operator[](const std::string &name)=0
Getter on a member of this PRMClassElementContainer.
virtual void setInputNode(const PRMClassElement< GUM_SCALAR > &elt, bool b)
Set the input flag value of id at b.
virtual void setOutputNode(const PRMClassElement< GUM_SCALAR > &elt, bool b)
Set the output flag value of id at b.
virtual const PRMClassElement< GUM_SCALAR > & get(const std::string &name) const =0
Constant getter on a member of this PRMClassElementContainer.
virtual const DAG & dag_() const =0
Abstract class representing an element of PRM class.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
Definition PRMClass.h:75
An PRMInterface is implemented by a Class<GUM_SCALAR> and defines a set of PRMReferenceSlot<GUM_SCALA...
const std::string & name() const
Returns the name of this object.
PRMObject(const std::string &name)
Constructor.
Definition PRMObject.cpp:62
Size NodeId
Type for node ids.
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46