aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
PRMInterface.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_INTERFACE_H
50#define GUM_INTERFACE_H
51
52#include <set>
53#include <string>
54#include <utility>
55
56#include <agrum/agrum.h>
57
60
61namespace gum {
62 namespace prm {
63
64 template < typename GUM_SCALAR >
65 class PRMClass;
66
79 template < typename GUM_SCALAR >
80 class PRMInterface: public PRMClassElementContainer< GUM_SCALAR > {
81 // ========================================================================
82 friend class PRMClass< GUM_SCALAR >;
83 // ========================================================================
84
85 public:
86 // ========================================================================
88 // ========================================================================
90
95 explicit PRMInterface(const std::string& name);
96
103 PRMInterface(const std::string& name,
105 bool delayInheritance = false);
106
109
111 virtual ~PRMInterface();
112
114 // ========================================================================
116 // ========================================================================
118
120 virtual typename PRMObject::prm_type obj_type() const;
121
124
126 virtual const PRMClassElement< GUM_SCALAR >& get(NodeId id) const;
127
137 void addArc(const std::string& tail, const std::string& head);
138
140 // ========================================================================
142 // ========================================================================
144
145 virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR >& elt) const;
146
149 virtual PRMClassElement< GUM_SCALAR >& get(const std::string& name);
150
153 virtual const PRMClassElement< GUM_SCALAR >& get(const std::string& name) const;
154
161
167
171
203
205 // ========================================================================
207 // ========================================================================
209
235 virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR >& cec) const;
236
243
249 const PRMInterface< GUM_SCALAR >& super() const;
250
255
260
265 void inheritInterface();
266
268 // ========================================================================
270 // ========================================================================
272
276
280
283 PRMClassElement< GUM_SCALAR >& operator[](const std::string& name);
284
287 const PRMClassElement< GUM_SCALAR >& operator[](const std::string& name) const;
288
290 // ========================================================================
292 // ========================================================================
294
297 const ClassEltIterator& end();
298
300 typename NodeProperty< PRMClassElement< GUM_SCALAR >* >::const_iterator;
302 const const_ClassEltIterator& end() const;
303
305
306 protected:
308 const DAG& dag_() const;
309
311 DAG& dag_();
312
317
321
322 private:
325
328
329 // ========================================================================
331 // ========================================================================
333
337
341
343 // ========================================================================
345 // ========================================================================
347
351
354
357
359 // ========================================================================
361 // ========================================================================
363
369
372
377
380
385
387 const PRMClassElement< GUM_SCALAR >* overloader);
388
390 PRMAttribute< GUM_SCALAR >* overloaded);
391
394
396
398 };
399
400
401#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
402 extern template class PRMInterface< double >;
403#endif
404
405
406 } /* namespace prm */
407} // namespace gum
408
410
411#endif /* GUM_INTERFACE_H */
Inline implementation of gum::prm::PRMInterface.
Headers of gum::PRMClassElement.
Headers of gum::PRMScalarAttribute.
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
PRMAttribute is a member of a Class in a PRM.
PRMClassElementContainer(const std::string &name)
Default constructor.
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
void findAllSubtypes_(Set< PRMClassElementContainer< GUM_SCALAR > * > &set)
Fills set with all the subtypes of this PRMInterface, this includes extensions and implementations.
typename NodeProperty< PRMClassElement< GUM_SCALAR > * >::const_iterator const_ClassEltIterator
PRMInterface(const std::string &name)
Default constructor.
Set< PRMAttribute< GUM_SCALAR > * > _attributes_
The sequence of PRMAttribute<GUM_SCALAR>s.
HashTable< std::string, PRMClassElement< GUM_SCALAR > * > _nameMap_
Mapping between a member's name and itself. Used for fast access to a member given it's name.
void _inheritInterface_(const PRMInterface< GUM_SCALAR > &i)
Proceed with the copy of i in this.
PRMInterface< GUM_SCALAR > * _superInterface_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
void _overloadReferenceSlot_(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const
Test if this PRMInterface is a sub PRMInterface of cec.
virtual PRMClassElement< GUM_SCALAR > & get(NodeId id)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(NodeId).
void _addImplementation_(PRMClass< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to the set of Class<GUM_SCALAR> which implements this PRMInterface.
void _addExtension_(PRMInterface< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to the set of Class<GUM_SCALAR> which implements this PRMInterface.
virtual ~PRMInterface()
Destructor.
Set< PRMReferenceSlot< GUM_SCALAR > * > _referenceSlots_
The sequence of PRMReferenceSlot<GUM_SCALAR>.
virtual PRMObject::prm_type obj_type() const
Implementation of pure virtual method of PRMObject.
void inheritInterface()
Inherits from this interface super interface, this should only be done when this inteface inheritance...
NodeProperty< PRMClassElement< GUM_SCALAR > * > _nodeIdMap_
Mapping between node's id and their name (being an attribute or a slot). Used for fast access to a me...
typename NodeProperty< PRMClassElement< GUM_SCALAR > * >::iterator ClassEltIterator
ClassEltIterator begin()
void _overloadAttribute_(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
bool _checkOverloadLegality_(const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
PRMClassElement< GUM_SCALAR > & operator[](NodeId id)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId).
const Set< PRMAttribute< GUM_SCALAR > * > & attributes() const
Returns the set of PRMAttribute<GUM_SCALAR> of this Class<GUM_SCALAR>.
void _addCastDescendants_(PRMAttribute< GUM_SCALAR > *start, PRMAttribute< GUM_SCALAR > *end)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
void updateDescendants_(const PRMClassElement< GUM_SCALAR > &elt)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>(constPRMClassElement<GUM_SCALAR>&).
const DAG & dag_() const
Returns a constant reference over this PRMInterface's DAG.
const ClassEltIterator & end()
virtual bool isOutputNode(const PRMClassElement< GUM_SCALAR > &elt) const
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(conststd::string&).
friend class PRMClass< GUM_SCALAR >
void addArc(const std::string &tail, const std::string &head)
An Interfance doesn't have any arc, this will raise an OperationNotAllowed exception.
Set< PRMClass< GUM_SCALAR > * > _implementations_
The set of Class<GUM_SCALAR> which implements this PRMInterface.
const Set< PRMReferenceSlot< GUM_SCALAR > * > & referenceSlots() const
Returns the set of PRMAggregate of this Class<GUM_SCALAR>.
DAG _dag_
The dag representing dependencies between formal attributes and slots.
PRMInterface< GUM_SCALAR > & operator=(const PRMInterface< GUM_SCALAR > &source)
Copy operator. Don't use it.
PRMInterface< GUM_SCALAR > & super()
Returns the superInterface of this PRMInterface.
NodeId add(PRMClassElement< GUM_SCALAR > *elt)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::add(PRMClassElement<GUM_SCALAR>*).
Set< PRMInterface< GUM_SCALAR > * > _extensions_
The set of Class<GUM_SCALAR> which implements this PRMInterface.
NodeId overload(PRMClassElement< GUM_SCALAR > *elt)
Add a new PRMClassElement<GUM_SCALAR> which overload an inherited PRMClassElement<GUM_SCALAR>.
Set< PRMClass< GUM_SCALAR > * > & implementations()
Returns the set of Class<GUM_SCALAR> implementing this PRMInterface.
const std::string & name() const
Returns the name of this object.
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition PRMObject.h:88
A PRMReferenceSlot represent a relation between two PRMClassElementContainer.
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46