aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
PRMSlotChain.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_SLOT_CHAIN_H
50#define GUM_SLOT_CHAIN_H
51
52#include <string>
53
56
57namespace gum {
58 namespace prm {
59
60 template < GUM_Numeric GUM_SCALAR >
61 class PRMClass;
62 template < GUM_Numeric GUM_SCALAR >
63 class PRMAttribute;
64
89 // ==========================================================================
90 template < GUM_Numeric GUM_SCALAR >
91 class PRMSlotChain: public PRMClassElement< GUM_SCALAR > {
92 public:
93 // ========================================================================
95 // ========================================================================
97
115 PRMSlotChain(std::string_view name, const Sequence< PRMClassElement< GUM_SCALAR >* >& chain);
116
135
142
144 ~PRMSlotChain() override;
145
147 // ========================================================================
149 // ========================================================================
151
154
156 PRMType& type() override;
157
159 const PRMType& type() const override;
160
161 // /// This is similar to the following call: this->lastElt().cpf()
162 // virtual Tensor<GUM_SCALAR>& cpf();
163
165 const Tensor< GUM_SCALAR >& cpf() const override;
166
169 bool isMultiple() const;
170
174
178
182
186
190
194
196 void addParent(const PRMClassElement< GUM_SCALAR >& elt) override;
197
199 void addChild(const PRMClassElement< GUM_SCALAR >& elt) override;
200
205
206 private:
208 PRMSlotChain& operator=(const PRMSlotChain& source);
209
210 // ========================================================================
212 // ========================================================================
214
217
220
223 void _copyLastElt_();
224
226 };
227
228
229#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
230 extern template class PRMSlotChain< double >;
231#endif
232
233
234 } /* namespace prm */
235} // namespace gum
236
238
239#endif /* GUM_SLOT_CHAIN_H */
Headers of gum::PRMAggregate.
Headers of gum::PRMClassElement.
Inline implementation of gum::PRMSlotChain<GUM_SCALAR>.
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:994
PRMAttribute is a member of a Class in a PRM.
<agrum/PRM/classElementContainer.h>
PRMClassElement(std::string_view name)
Default constructor of a PRMClassElement.
ClassElementType
Returns true if obj_ptr is of type PRMReferenceSlot.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
Definition PRMClass.h:77
const std::string & name() const
Returns the name of this object.
A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum...
bool _isMultiple_
Flag indicating if this slot chain is multiple or not.
void _copyLastElt_()
Copy the last element, this prevents unwanted DuplicateElement exceptions.
Sequence< PRMClassElement< GUM_SCALAR > * > * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
PRMType & type() override
This is similar to the following call: this->lastElt().type().
PRMClassElement< GUM_SCALAR > & lastElt()
Returns the last element of the slot chain, typically this is an gum::PRMAttribute or a gum::PRMAggre...
Sequence< PRMClassElement< GUM_SCALAR > * > & chain()
Return the sequence representing the chain of elements in this PRMSlotChain.
void addParent(const PRMClassElement< GUM_SCALAR > &elt) override
See gum::PRMClassElement<GUM_SCALAR>::addParent_().
void addChild(const PRMClassElement< GUM_SCALAR > &elt) override
See gum::PRMClassElement<GUM_SCALAR>::addChild_().
PRMClassElement< GUM_SCALAR >::ClassElementType elt_type() const override
See gum::PRMClassElement<GUM_SCALAR>::elt_type().
PRMSlotChain(std::string_view name, const Sequence< PRMClassElement< GUM_SCALAR > * > &chain)
Default constructor.
bool isMultiple() const
Return true if this slot chain contains at least one multiple reference slot.
~PRMSlotChain() override
Destructor.
const Tensor< GUM_SCALAR > & cpf() const override
This is similar to the following call: this->lastElt().cpf().
PRMClassElementContainer< GUM_SCALAR > & end()
Returns the PRMClassElement<GUM_SCALAR>Container over which this slot chain ends.
PRMAttribute< GUM_SCALAR > * getCastDescendant() const override
Raise a gum::OperationNotAllowed exception See gum::PRMClassElement<GUM_SCALAR>::getCastDescendant().
PRMSlotChain & operator=(const PRMSlotChain &source)
Copy operator. Don't use it.
This is a decoration of the DiscreteVariable class.
Definition PRMType.h:78
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46