aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
PRMReferenceSlot.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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
93  elt_type() const;
94 
95  /**
96  * Returns the type of this slot, which is a PRMClassElementContainer
97  * (it is not the type of PRMObject).
98  */
100 
101  /**
102  * Returns the type of this slot, which is a PRMClassElementContainer
103  * (it is not the type of PRMObject).
104  */
105  const PRMClassElementContainer< GUM_SCALAR >& slotType() const;
106 
107  /**
108  * Returns true if this reference slot is an array.
109  */
110  bool isArray() const;
111 
112  /// See gum::PRMClassElement::addParent().
113  virtual void addParent(const PRMClassElement< GUM_SCALAR >& elt);
114 
115  /// See gum::PRMClassElement::addChild().
116  virtual void addChild(const PRMClassElement< GUM_SCALAR >& elt);
117 
118  /// @}
119  // ========================================================================
120  /// @name Not allowed operations on a PRMReferenceSlot.
121  // ========================================================================
122  /// @{
123 
124  /// @brief Raise an OperationNotAllowed.
125  /// See gum::PRMClassElement::type().
126  virtual PRMType& type();
127 
128  /// @brief Raise an OperationNotAllowed.
129  /// See gum::PRMClassElement::type().
130  virtual const PRMType& type() const;
131 
132  /// @brief Raise an OperationNotAllowed.
133  /// See gum::PRMClassElement::cpf().
134  virtual Potential< GUM_SCALAR >& cpf();
135 
136  /// @brief Raise an OperationNotAllowed.
137  /// See gum::PRMClassElement::cpf().
138  virtual const Potential< GUM_SCALAR >& cpf() const;
139 
140  /// @brief Raise an OperationNotAllowed.
141  /// See gum::PRMClassElement::getCastDescendant().
142  virtual PRMAttribute< GUM_SCALAR >* getCastDescendant() const;
143 
144  /// @}
145  private:
146  // ========================================================================
147  /// @name Private methods
148  // ========================================================================
149  // @{
150 
151  /// Copy constructor. Don't use it.
152  PRMReferenceSlot(const PRMReferenceSlot< GUM_SCALAR >& source);
153 
154  /// Copy operator. Don't use it.
155  PRMReferenceSlot& operator=(const PRMReferenceSlot< GUM_SCALAR >& from);
156 
157  /// @}
158  // ========================================================================
159  /// @name Private members
160  // ========================================================================
161  // @{
162 
163  /// The type of this PRMReferenceSlot.
165 
166  /// Flag indicating if this slot is an array.
167  bool isArray__;
168 
169  /// @}
170  };
171 
172 
173 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
174  extern template class PRMReferenceSlot< double >;
175 #endif
176 
177 
178  } /* namespace prm */
179 } // namespace gum
180 
181 #include <agrum/PRM/elements/PRMReferenceSlot_tpl.h>
182 
183 #endif /* GUM_CLASS_ELEMENT_H */
bool isArray() const
Returns true if this reference 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.
bool isArray__
Flag indicating if this slot is an array.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
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().
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().
PRMClassElementContainer< GUM_SCALAR > & slotType__
The type of this PRMReferenceSlot.
virtual PRMType & type()
Raise an OperationNotAllowed. See gum::PRMClassElement::type().