aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
PRMObject.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_PRM_OBJECT_H
50#define GUM_PRM_OBJECT_H
51
52#include <string>
53
54#include <agrum/agrum.h>
55
56namespace gum {
57
58 namespace prm {
74
75 class PRMObject {
76 public:
77 // ==========================================================================
79 // ==========================================================================
81
89
90 static std::string LEFT_CAST() { return "("; }
91
92 static std::string RIGHT_CAST() { return ")"; }
93
95 static std::string enum2str(prm_type type) {
96 switch (type) {
97 case prm_type::CLASS : return "PRMType::CLASS";
98
99 case prm_type::CLASS_ELT : return "PRMType::CLASS_ELT";
100
101 case prm_type::TYPE : return "PRMType::TYPE";
102
103 case prm_type::SYSTEM : return "PRMType::SYSTEM";
104
105 case prm_type::INSTANCE : return "PRMType::INSTANCE";
106
107 case prm_type::PRM_INTERFACE : return "PRMType::PRM_INTERFACE";
108
109 default : return "unknown";
110 }
111 }
112
114 static INLINE bool isClass(const PRMObject& obj) { return obj.obj_type() == prm_type::CLASS; }
115
117 static INLINE bool isInterface(const PRMObject& obj) {
118 return obj.obj_type() == prm_type::PRM_INTERFACE;
119 }
120
122 static INLINE bool isInstance(const PRMObject& obj) {
123 return obj.obj_type() == prm_type::INSTANCE;
124 }
125
127 // ==========================================================================
129 // ==========================================================================
131
136 explicit PRMObject(const std::string& name);
137
141 PRMObject(const PRMObject& source);
142
146 PRMObject(PRMObject&& source);
147
151 virtual ~PRMObject();
152
154 // ==========================================================================
156 // ==========================================================================
158
162 const std::string& name() const;
163
168 void name(const std::string& name);
169
173 virtual prm_type obj_type() const = 0;
174
176 // ==========================================================================
178 // ==========================================================================
180
184 bool operator==(const PRMObject& obj) const;
185
189 bool operator!=(const PRMObject& obj) const;
190
194 PRMObject& operator=(const PRMObject& source);
195
199 PRMObject& operator=(PRMObject&& source);
200
202
203 private:
204 // ==========================================================================
206 // ==========================================================================
208
209 // The name of this object
210 // ======================================================================
211 std::string _name_;
212
214 };
215
217 std::ostream& operator<<(std::ostream& out, PRMObject::prm_type obj_type);
218
219 // list of declarations of PRMObjects
220 class PRMType;
221 template < typename GUM_SCALAR >
222 class PRMClassElement;
223 template < typename GUM_SCALAR >
225 template < typename GUM_SCALAR >
226 class PRMAggregate;
227 template < typename GUM_SCALAR >
228 class PRMInterface;
229 template < typename GUM_SCALAR >
230 class PRMAttribute;
231 template < typename GUM_SCALAR >
232 class PRMSlotChain;
233 template < typename GUM_SCALAR >
234 class PRMReferenceSlot;
235 template < typename GUM_SCALAR >
236 class PRMClass;
237 template < typename GUM_SCALAR >
238 class PRMInstance;
239 template < typename GUM_SCALAR >
240 class PRMSystem;
241
242 } /* namespace prm */
243} /* namespace gum */
244
245#ifndef GUM_NO_INLINE
247#endif // GUM_NO_INLINE
248
249#endif /* GUM_PRM_OBJECT_H */
Inline implementation of PRMObject.
PRMAttribute is a member of a Class in a PRM.
<agrum/PRM/classElementContainer.h>
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 PRMInstance is a Bayesian network fragment defined by a Class and used in a PRMSystem.
Definition PRMInstance.h:79
An PRMInterface is implemented by a Class<GUM_SCALAR> and defines a set of PRMReferenceSlot<GUM_SCALA...
Abstract base class for any element defined in a PRM.
Definition PRMObject.h:75
static INLINE bool isInterface(const PRMObject &obj)
Returns true if obj_ptr is of type PRMInterface.
Definition PRMObject.h:117
const std::string & name() const
Returns the name of this object.
bool operator==(const PRMObject &obj) const
To PRMObject are equal if they have the same name (which is unique).
static std::string enum2str(prm_type type)
Returns the string representation of a PRMObject.
Definition PRMObject.h:95
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition PRMObject.h:88
bool operator!=(const PRMObject &obj) const
To PRMObject are equal if they have the same name (which is unique).
PRMObject & operator=(const PRMObject &source)
Copy operator.
Definition PRMObject.cpp:87
std::string _name_
Definition PRMObject.h:211
PRMObject(const std::string &name)
Constructor.
Definition PRMObject.cpp:62
static INLINE bool isClass(const PRMObject &obj)
Returns true if obj_ptr is of type Class.
Definition PRMObject.h:114
virtual ~PRMObject()
Destructor.
Definition PRMObject.cpp:81
virtual prm_type obj_type() const =0
Returns the type of this object.
static std::string LEFT_CAST()
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.
Definition PRMObject.h:92
static INLINE bool isInstance(const PRMObject &obj)
Returns true if obj_ptr is of type PRMInstance.
Definition PRMObject.h:122
A PRMReferenceSlot represent a relation between two PRMClassElementContainer.
A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum...
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition PRMSystem.h:70
This is a decoration of the DiscreteVariable class.
Definition PRMType.h:78
namespace for all probabilistic relational models entities
Definition agrum.h:68
std::ostream & operator<<(std::ostream &out, PRMObject::prm_type obj_type)
For printing PRMType easily.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46