aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
PRMFormAttribute.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::PRMFormAttribute.
25  *
26  * @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 
29 #ifndef GUM_FORM_ATTRIBUTE_H
30 #define GUM_FORM_ATTRIBUTE_H
31 
32 #include <agrum/PRM/elements/PRMAttribute.h>
33 
34 #include <agrum/PRM/elements/PRMClass.h>
35 
36 namespace gum {
37  namespace prm {
38 
39  /**
40  * @class PRMFormAttribute formAttribute.h
41  *<agrum/PRM/elements/formAttribute.h>
42  * @brief PRMFormAttribute is a member of a Class in a PRM.
43  *
44  * @see PRM PRMFactory Class PRMClassElement PRMType<GUM_SCALAR> Potential
45  *PRMAttribute
46  * @ingroup prm_group
47  */
48  template < typename GUM_SCALAR >
50  public:
51  PRMFormAttribute(const PRMClass< GUM_SCALAR >& c,
52  const std::string& name,
53  const PRMType& type,
54  MultiDimImplementation< std::string >* impl
55  = new MultiDimArray< std::string >());
56 
57  virtual ~PRMFormAttribute();
58 
59  /// See gum::prm::PRMAttribute.
60  virtual PRMAttribute< GUM_SCALAR >* newFactory(const PRMClass< GUM_SCALAR >& c) const;
61 
62  /// See gum::prm::PRMAttribute.
63  virtual PRMAttribute< GUM_SCALAR >*
64  copy(Bijection< const DiscreteVariable*, const DiscreteVariable* > bij) const;
65 
66  /// See gum::prm::PRMAttribute.
67  virtual void copyCpf(const Bijection< const DiscreteVariable*, const DiscreteVariable* >& bif,
68  const PRMAttribute< GUM_SCALAR >& source);
69 
70  /// See gum::prm::PRMAttribute.
71  virtual typename PRMClassElement< GUM_SCALAR >::ClassElementType elt_type() const;
72 
73  /// See gum::prm::PRMAttribute.
74  virtual PRMType& type();
75 
76  /// See gum::prm::PRMAttribute.
77  virtual const PRMType& type() const;
78 
79  /// See gum::prm::PRMAttribute.
80  virtual const Potential< GUM_SCALAR >& cpf() const;
81 
82  /// See gum::prm::PRMAttribute.
83  virtual void addParent(const PRMClassElement< GUM_SCALAR >& elt);
84 
85  /// See gum::prm::PRMAttribute.
86  virtual void addChild(const PRMClassElement< GUM_SCALAR >& elt);
87 
88  /// See gum::prm::PRMAttribute.
89  virtual PRMAttribute< GUM_SCALAR >* getCastDescendant() const;
90 
91  /// See gum::prm::PRMAttribute.
92  virtual void setAsCastDescendant(PRMAttribute< GUM_SCALAR >* attr);
93  virtual void becomeCastDescendant(PRMType& subtype);
94 
96  virtual const MultiDimImplementation< std::string >& formulas() const;
97 
98  /// Swap old_type with new_type in the PRMClassElement cpt.
99  virtual void swap(const PRMType& old_type, const PRMType& new_type);
100 
101  protected:
102  virtual PRMType* type_();
103  virtual void type_(PRMType* t);
104 
105  private:
106  PRMFormAttribute(const PRMFormAttribute& source);
107  PRMFormAttribute& operator=(const PRMFormAttribute& source);
108 
109  /// The random variable type of this attribute
111 
112  /// A pointer on the Potential of this attribute
114 
115  /// A pointer on the Potential of this attribute
117 
118  /// A pointe toward the class of this attribute
120 
121  void _fillCpf_() const;
122  };
123 
124 
125 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
126  extern template class PRMFormAttribute< double >;
127 #endif
128 
129 
130  } /* namespace prm */
131 } // namespace gum
132 
133 #include <agrum/PRM/elements/PRMFormAttribute_tpl.h>
134 
135 #endif /* GUM_ATTRIBUTE_H */
virtual void addParent(const PRMClassElement< GUM_SCALAR > &elt)
See gum::prm::PRMAttribute.
virtual void setAsCastDescendant(PRMAttribute< GUM_SCALAR > *attr)
See gum::prm::PRMAttribute.
virtual void swap(const PRMType &old_type, const PRMType &new_type)
Swap old_type with new_type in the PRMClassElement cpt.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual PRMAttribute< GUM_SCALAR > * newFactory(const PRMClass< GUM_SCALAR > &c) const
See gum::prm::PRMAttribute.
virtual void type_(PRMType *t)
virtual const PRMType & type() const
See gum::prm::PRMAttribute.
PRMFormAttribute(const PRMFormAttribute &source)
virtual PRMClassElement< GUM_SCALAR >::ClassElementType elt_type() const
See gum::prm::PRMAttribute.
virtual MultiDimImplementation< std::string > & formulas()
virtual void copyCpf(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bif, const PRMAttribute< GUM_SCALAR > &source)
See gum::prm::PRMAttribute.
Potential< GUM_SCALAR > * _cpf_
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * _formulas_
A pointer on the Potential of this attribute.
PRMFormAttribute & operator=(const PRMFormAttribute &source)
virtual PRMAttribute< GUM_SCALAR > * getCastDescendant() const
See gum::prm::PRMAttribute.
const PRMClass< GUM_SCALAR > * _class_
A pointe toward the class of this attribute.
PRMType * _type_
The random variable type of this attribute.
virtual const Potential< GUM_SCALAR > & cpf() const
See gum::prm::PRMAttribute.
PRMFormAttribute(const PRMClass< GUM_SCALAR > &c, const std::string &name, const PRMType &type, MultiDimImplementation< std::string > *impl=new MultiDimArray< std::string >())
virtual void addChild(const PRMClassElement< GUM_SCALAR > &elt)
See gum::prm::PRMAttribute.
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)
virtual PRMAttribute< GUM_SCALAR > * copy(Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const
See gum::prm::PRMAttribute.
virtual void becomeCastDescendant(PRMType &subtype)
Change this attribute to be a cast descendant of a an attribute with type subtype.
virtual const MultiDimImplementation< std::string > & formulas() const
virtual PRMType & type()
See gum::prm::PRMAttribute.