aGrUM 3.1.1
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-2026 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-2026 *
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
61#include <string_view>
62
63namespace gum {
64 namespace prm {
65
66 template < GUM_Numeric GUM_SCALAR >
67 class PRMClass;
68
81 template < GUM_Numeric GUM_SCALAR >
82 class PRMInterface: public PRMClassElementContainer< GUM_SCALAR > {
83 // ========================================================================
84 friend class PRMClass< GUM_SCALAR >;
85 // ========================================================================
86
87 public:
88 // ========================================================================
90 // ========================================================================
92
97 explicit PRMInterface(std::string_view name);
98
105 PRMInterface(std::string_view name,
107 bool delayInheritance = false);
108
111
113 ~PRMInterface() override;
114
116 // ========================================================================
118 // ========================================================================
120
122 typename PRMObject::prm_type obj_type() const override;
123
126
128 const PRMClassElement< GUM_SCALAR >& get(NodeId id) const override;
129
139 void addArc(std::string_view tail, std::string_view head) override;
140
142 // ========================================================================
144 // ========================================================================
146
147 bool isOutputNode(const PRMClassElement< GUM_SCALAR >& elt) const override;
148
151 PRMClassElement< GUM_SCALAR >& get(std::string_view name) override;
152
155 const PRMClassElement< GUM_SCALAR >& get(std::string_view name) const override;
156
163
169
173
205
207 // ========================================================================
209 // ========================================================================
211
237 bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR >& cec) const override;
238
245
251 const PRMInterface< GUM_SCALAR >& super() const;
252
257
262
267 void inheritInterface();
268
270 // ========================================================================
272 // ========================================================================
274
278
281 const PRMClassElement< GUM_SCALAR >& operator[](NodeId id) const override;
282
285 PRMClassElement< GUM_SCALAR >& operator[](std::string_view name) override;
286
289 const PRMClassElement< GUM_SCALAR >& operator[](std::string_view name) const override;
290
292 // ========================================================================
294 // ========================================================================
296
299 const ClassEltIterator& end();
300
302 typename NodeProperty< PRMClassElement< GUM_SCALAR >* >::const_iterator;
304 const const_ClassEltIterator& end() const;
305
307
308 protected:
310 const DAG& dag_() const override;
311
313 DAG& dag_() override;
314
319
322 void updateDescendants_(const PRMClassElement< GUM_SCALAR >& elt) override;
323
324 private:
327
330
331 // ========================================================================
333 // ========================================================================
335
339
343
345 // ========================================================================
347 // ========================================================================
349
353
356
359
361 // ========================================================================
363 // ========================================================================
365
371
374
379
382
387
389 const PRMClassElement< GUM_SCALAR >* overloader);
390
392 PRMAttribute< GUM_SCALAR >* overloaded);
393
396
398
400 };
401
402
403#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
404 extern template class PRMInterface< double >;
405#endif
406
407
408 } /* namespace prm */
409} // namespace gum
410
412
413#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:640
Representation of a set.
Definition set.h:129
PRMAttribute is a member of a Class in a PRM.
PRMClassElementContainer(std::string_view 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:77
typename NodeProperty< PRMClassElement< GUM_SCALAR > * >::const_iterator const_ClassEltIterator
void _addImplementation_(PRMClass< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to the set of Class<GUM_SCALAR> which implements this PRMInterface.
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....
const Set< PRMAttribute< GUM_SCALAR > * > & attributes() const
Returns the set of PRMAttribute<GUM_SCALAR> of this Class<GUM_SCALAR>.
bool isOutputNode(const PRMClassElement< GUM_SCALAR > &elt) const override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(conststd::string&).
void _overloadReferenceSlot_(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
NodeId add(PRMClassElement< GUM_SCALAR > *elt) override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::add(PRMClassElement<GUM_SCALAR>*).
Set< PRMClass< GUM_SCALAR > * > & implementations()
Returns the set of Class<GUM_SCALAR> implementing this PRMInterface.
void addArc(std::string_view tail, std::string_view head) override
An Interfance doesn't have any arc, this will raise an OperationNotAllowed exception.
Set< PRMReferenceSlot< GUM_SCALAR > * > _referenceSlots_
The sequence of PRMReferenceSlot<GUM_SCALAR>.
PRMInterface< GUM_SCALAR > & super()
Returns the superInterface of this PRMInterface.
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...
const ClassEltIterator & end()
PRMClassElement< GUM_SCALAR > & operator[](NodeId id) override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId).
typename NodeProperty< PRMClassElement< GUM_SCALAR > * >::iterator ClassEltIterator
PRMClassElement< GUM_SCALAR > & get(NodeId id) override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(NodeId).
void _overloadAttribute_(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
NodeId overload(PRMClassElement< GUM_SCALAR > *elt) override
Add a new PRMClassElement<GUM_SCALAR> which overload an inherited PRMClassElement<GUM_SCALAR>.
PRMObject::prm_type obj_type() const override
Implementation of pure virtual method of PRMObject.
bool _checkOverloadLegality_(const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
const DAG & dag_() const override
Returns a constant reference over this PRMInterface's DAG.
~PRMInterface() override
Destructor.
void _addCastDescendants_(PRMAttribute< GUM_SCALAR > *start, PRMAttribute< GUM_SCALAR > *end)
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this....
ClassEltIterator begin()
void updateDescendants_(const PRMClassElement< GUM_SCALAR > &elt) override
See gum::prm::PRMClassElementContainer<GUM_SCALAR>(constPRMClassElement<GUM_SCALAR>&).
PRMInterface(std::string_view name)
Default constructor.
void _addExtension_(PRMInterface< GUM_SCALAR > *c)
Add an Class<GUM_SCALAR> to 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>.
friend class PRMClass< GUM_SCALAR >
Set< PRMClass< GUM_SCALAR > * > _implementations_
The set of Class<GUM_SCALAR> which implements this PRMInterface.
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.
bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const override
Test if this PRMInterface is a sub PRMInterface of cec.
Set< PRMInterface< GUM_SCALAR > * > _extensions_
The set of Class<GUM_SCALAR> which implements this PRMInterface.
void findAllSubtypes_(Set< PRMClassElementContainer< GUM_SCALAR > * > &set) override
Fills set with all the subtypes of this PRMInterface, this includes extensions and implementations.
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:90
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