aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
PRMClassElement_tpl.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#pragma once
42
43
52
53namespace gum {
54 namespace prm {
55
56 template < GUM_Numeric GUM_SCALAR >
58 GUM_CONSTRUCTOR(PRMClassElement);
59 }
60
61 template < GUM_Numeric GUM_SCALAR >
66
67 template < GUM_Numeric GUM_SCALAR >
71
72 template < GUM_Numeric GUM_SCALAR >
76
77 template < GUM_Numeric GUM_SCALAR >
81
82 template < GUM_Numeric GUM_SCALAR >
86
87 template < GUM_Numeric GUM_SCALAR >
88 const std::string& PRMClassElement< GUM_SCALAR >::safeName() const {
89 return safeName_;
90 }
91
92 template < GUM_Numeric GUM_SCALAR >
93 std::string PRMClassElement< GUM_SCALAR >::cast(const PRMType& t) const {
94 if (type().isSubTypeOf(t)) {
96 } else {
97 GUM_ERROR(OperationNotAllowed, "illegal cast")
98 }
99 }
100
101 template < GUM_Numeric GUM_SCALAR >
103 switch (type) {
104 case prm_attribute : return "prm_attribute";
105
106 case prm_aggregate : return "prm_aggregate";
107
108 case prm_refslot : return "prm_refslot";
109
110 case prm_slotchain : return "prm_slotchain";
111
112 case prm_parameter : return "prm_parameter";
113
114 default : return "unknown";
115 }
116 }
117
118 template < GUM_Numeric GUM_SCALAR >
122
123 template < GUM_Numeric GUM_SCALAR >
127
128 template < GUM_Numeric GUM_SCALAR >
132
133 template < GUM_Numeric GUM_SCALAR >
137
138 template < GUM_Numeric GUM_SCALAR >
142
143 } /* namespace prm */
144} /* namespace gum */
Headers of gum::PRMClassElement.
Headers of Class.
Exception : operation not allowed.
~PRMClassElement() override
Destructor of this class.
PRMClassElement(std::string_view name)
Default constructor of a PRMClassElement.
static INLINE bool isAggregate(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMAggregate.
NodeId _id_
The node's id of this element.
static INLINE bool isReferenceSlot(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMReferenceSlot.
static INLINE bool isParameter(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMParameter.
virtual std::string cast(const PRMType &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.
static std::string enum2str(ClassElementType type)
Returns true if obj_ptr is of type PRMReferenceSlot.
virtual ClassElementType elt_type() const =0
Return the type of class element this object is.
ClassElementType
Returns true if obj_ptr is of type PRMReferenceSlot.
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
PRMObject::prm_type obj_type() const override
virtual void setId(NodeId id)
Used to assign the id of this element.
static INLINE bool isSlotChain(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMSlotChain.
NodeId id() const
Returns the NodeId of this element in it's class DAG.
const std::string & safeName() const
Returns the safe name of this PRMClassElement, if any.
std::string safeName_
The safe name of this PRMClassElement.
PRMObject(std::string_view name)
Constructor.
Definition PRMObject.cpp:62
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
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
This is a decoration of the DiscreteVariable class.
Definition PRMType.h:78
const std::string & name() const
Returns the name of this object.
Definition PRMType_inl.h:79
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
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