aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
PRMReferenceSlot.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Headers of gum::PRMClassElement.
25  *
26  * @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 
29 #ifndef GUM_REFERENCE_SLOT_H
30 #define GUM_REFERENCE_SLOT_H
31 
32 #include <agrum/PRM/elements/PRMClassElement.h>
33 #include <agrum/PRM/elements/PRMClassElementContainer.h>
34 
35 namespace gum {
36  namespace prm {
37 
38  /**
39  * @class PRMReferenceSlot
40  * @headerfile referenceSlot.h <agrum/PRM/referenceSlot.h>
41  * @brief A PRMReferenceSlot represent a relation between two
42  * PRMClassElementContainer.
43  *
44  * A reference slot is a relation between two PRMClassElementContainer in a
45  *PRM. A
46  * PRMReferenceSlot is considered as an element of a
47  *PRMClassElementContainer
48  *which
49  * slot type is a PRMClassElementContainer.
50  *
51  * A PRMReferenceSlot is defined by it's slot type (i.e. it's range), it's
52  * PRMClassElementContainer (it's domain), it's name and if it is a multiple
53  * reference (the isArray() flag).
54  *
55  * @see PRM PRMFactory PRMClassElementContainer PRMClassElement
56  * @ingroup prm_group
57  */
58  // ==========================================================================
59  template < typename GUM_SCALAR >
61  public:
62  // ========================================================================
63  /// @name Protected constructors & destructor.
64  // ========================================================================
65  /// @{
66 
67  /**
68  * Default constructor
69  *
70  * @param name The name of this element.
71  * @param type The type of this reference slot.
72  * @param isArray Determine if this reference slot is multiple or not.
73  */
74  PRMReferenceSlot(const std::string& name,
75  PRMClassElementContainer< GUM_SCALAR >& type,
76  bool isArray = false);
77 
78  /**
79  * Destructor.
80  */
81  virtual ~PRMReferenceSlot();
82 
83  /// @}
84  // ========================================================================
85  /// @name Getters & setters
86  // ========================================================================
87  /// @{
88 
89  /**
90  * Implementation of the pure virtual method of PRMObject.
91  */
92  virtual typename PRMClassElement< GUM_SCALAR >::ClassElementType elt_type() const;
93 
94  /**
95  * Returns the type of this slot, which is a PRMClassElementContainer
96  * (it is not the type of PRMObject).
97  */
99 
100  /**
101  * Returns the type of this slot, which is a PRMClassElementContainer
102  * (it is not the type of PRMObject).
103  */
104  const PRMClassElementContainer< GUM_SCALAR >& slotType() const;
105 
106  /**
107  * Returns true if this reference slot is an array.
108  */
109  bool isArray() const;
110 
111  /// See gum::PRMClassElement::addParent().
112  virtual void addParent(const PRMClassElement< GUM_SCALAR >& elt);
113 
114  /// See gum::PRMClassElement::addChild().
115  virtual void addChild(const PRMClassElement< GUM_SCALAR >& elt);
116 
117  /// @}
118  // ========================================================================
119  /// @name Not allowed operations on a PRMReferenceSlot.
120  // ========================================================================
121  /// @{
122 
123  /// @brief Raise an OperationNotAllowed.
124  /// See gum::PRMClassElement::type().
125  virtual PRMType& type();
126 
127  /// @brief Raise an OperationNotAllowed.
128  /// See gum::PRMClassElement::type().
129  virtual const PRMType& type() const;
130 
131  /// @brief Raise an OperationNotAllowed.
132  /// See gum::PRMClassElement::cpf().
133  virtual Potential< GUM_SCALAR >& cpf();
134 
135  /// @brief Raise an OperationNotAllowed.
136  /// See gum::PRMClassElement::cpf().
137  virtual const Potential< GUM_SCALAR >& cpf() const;
138 
139  /// @brief Raise an OperationNotAllowed.
140  /// See gum::PRMClassElement::getCastDescendant().
141  virtual PRMAttribute< GUM_SCALAR >* getCastDescendant() const;
142 
143  /// @}
144  private:
145  // ========================================================================
146  /// @name Private methods
147  // ========================================================================
148  // @{
149 
150  /// Copy constructor. Don't use it.
151  PRMReferenceSlot(const PRMReferenceSlot< GUM_SCALAR >& source);
152 
153  /// Copy operator. Don't use it.
154  PRMReferenceSlot& operator=(const PRMReferenceSlot< GUM_SCALAR >& from);
155 
156  /// @}
157  // ========================================================================
158  /// @name Private members
159  // ========================================================================
160  // @{
161 
162  /// The type of this PRMReferenceSlot.
164 
165  /// Flag indicating if this slot is an array.
166  bool _isArray_;
167 
168  /// @}
169  };
170 
171 
172 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
173  extern template class PRMReferenceSlot< double >;
174 #endif
175 
176 
177  } /* namespace prm */
178 } // namespace gum
179 
180 #include <agrum/PRM/elements/PRMReferenceSlot_tpl.h>
181 
182 #endif /* GUM_CLASS_ELEMENT_H */
bool isArray() const
Returns true if this reference slot is an array.
bool _isArray_
Flag indicating if this slot is an array.
virtual const PRMType & type() const
Raise an OperationNotAllowed. See gum::PRMClassElement::type().
PRMReferenceSlot(const PRMReferenceSlot< GUM_SCALAR > &source)
Copy constructor. Don&#39;t use it.
virtual ~PRMReferenceSlot()
Destructor.
virtual Potential< GUM_SCALAR > & cpf()
Raise an OperationNotAllowed. See gum::PRMClassElement::cpf().
PRMReferenceSlot & operator=(const PRMReferenceSlot< GUM_SCALAR > &from)
Copy operator. Don&#39;t use it.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual void addParent(const PRMClassElement< GUM_SCALAR > &elt)
See gum::PRMClassElement::addParent().
virtual const Potential< GUM_SCALAR > & cpf() const
Raise an OperationNotAllowed. See gum::PRMClassElement::cpf().
PRMClassElementContainer< GUM_SCALAR > & _slotType_
The type of this PRMReferenceSlot.
const PRMClassElementContainer< GUM_SCALAR > & slotType() const
Returns the type of this slot, which is a PRMClassElementContainer (it is not the type of PRMObject)...
PRMClassElementContainer< GUM_SCALAR > & slotType()
Returns the type of this slot, which is a PRMClassElementContainer (it is not the type of PRMObject)...
virtual PRMClassElement< GUM_SCALAR >::ClassElementType elt_type() const
Implementation of the pure virtual method of PRMObject.
PRMReferenceSlot(const std::string &name, PRMClassElementContainer< GUM_SCALAR > &type, bool isArray=false)
Default constructor.
virtual void addChild(const PRMClassElement< GUM_SCALAR > &elt)
See gum::PRMClassElement::addChild().
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)
virtual PRMAttribute< GUM_SCALAR > * getCastDescendant() const
Raise an OperationNotAllowed. See gum::PRMClassElement::getCastDescendant().
virtual PRMType & type()
Raise an OperationNotAllowed. See gum::PRMClassElement::type().