aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
O3TypeFactory.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 for the O3TypeFactory class.
25  *
26  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
27  * @author Lionel TORTI
28  */
29 
30 #include <memory>
31 #include <string>
32 
33 #include <agrum/PRM/PRM.h>
34 #include <agrum/PRM/PRMFactory.h>
35 #include <agrum/PRM/o3prm/O3NameSolver.h>
36 #include <agrum/PRM/o3prm/O3prm.h>
37 #include <agrum/PRM/o3prm/errors.h>
38 #include <agrum/tools/core/errorsContainer.h>
39 #include <agrum/tools/core/hashTable.h>
40 #include <agrum/tools/core/set.h>
41 
42 #ifndef GUM_PRM_O3PRM_O3TYPE_FACTORY_H
43 # define GUM_PRM_O3PRM_O3TYPE_FACTORY_H
44 
45 namespace gum {
46  namespace prm {
47  namespace o3prm {
48 
49  /**
50  * @class O3TypeFactory
51  * @headerfile O3TypeFactory.h <agrum/PRM/o3prm/O3TypeFactory.h>
52  * @ingroup o3prm_group
53  *
54  * @brief Builds gum::prm::PRMType from gum::prm::o3prm::O3Type,
55  * gum::prm::o3prm::O3IntType and gum::prm::o3prm::O3RealType.
56  *
57  * @tparam GUM_SCALAR The scalar type used by the gum::prm::PRM.
58  */
59  template < typename GUM_SCALAR >
60  class O3TypeFactory {
61  public:
62  O3TypeFactory(PRM< GUM_SCALAR >& prm,
63  O3PRM& o3_prm,
64  O3NameSolver< GUM_SCALAR >& solver,
65  ErrorsContainer& errors);
66  O3TypeFactory(const O3TypeFactory< GUM_SCALAR >& src);
67  O3TypeFactory(O3TypeFactory< GUM_SCALAR >&& src);
68  ~O3TypeFactory();
69  O3TypeFactory& operator=(const O3TypeFactory< GUM_SCALAR >& src);
70  O3TypeFactory& operator=(O3TypeFactory< GUM_SCALAR >&& src);
71 
72  void build();
73 
74  private:
79 
80  bool _build_;
81 
90 
91  void _buildTypes_();
92  void _buildIntTypes_();
93  void _buildRealTypes_();
94 
95  bool _isPrimitiveType_(O3Type& type);
96 
97  bool _checkO3Types_();
99  bool _addTypes2Dag_();
100  bool _addArcs2Dag_();
101  bool _checkLabels_(O3Type& type);
102 
104 
105  bool _checkO3IntTypes_();
106  bool _checkO3RealTypes_();
107  };
108 
109  } // namespace o3prm
110  } // namespace prm
111 } // namespace gum
112 
113 // always include the implementation of the templates
114 # include <agrum/PRM/o3prm/O3TypeFactory_tpl.h>
115 
116 
117 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
118 extern template class gum::prm::o3prm::O3TypeFactory< double >;
119 # endif
120 
121 
122 #endif // GUM_PRM_O3PRM_O3TYPE_FACTORY_H
Builds gum::prm::PRMType from gum::prm::o3prm::O3Type, gum::prm::o3prm::O3IntType and gum::prm::o3prm...
Definition: O3TypeFactory.h:60
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
HashTable< NodeId, O3Type *> _nodeMap_
Definition: O3TypeFactory.h:85
std::vector< O3IntType *> _o3IntTypes_
Definition: O3TypeFactory.h:88
HashTable< std::string, O3Type *> _superMap_
Definition: O3TypeFactory.h:82
O3TypeFactory(O3TypeFactory< GUM_SCALAR > &&src)
HashTable< std::string, gum::NodeId > _nameMap_
Definition: O3TypeFactory.h:83
std::vector< O3RealType *> _o3RealTypes_
Definition: O3TypeFactory.h:89
O3TypeFactory & operator=(O3TypeFactory< GUM_SCALAR > &&src)
PRM< GUM_SCALAR > * _prm_
Definition: O3TypeFactory.h:75
HashTable< std::string, O3Type *> _typeMap_
Definition: O3TypeFactory.h:84
O3TypeFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)
O3TypeFactory(const O3TypeFactory< GUM_SCALAR > &src)
std::vector< O3Type *> _o3Types_
Definition: O3TypeFactory.h:87
bool _isPrimitiveType_(O3Type &type)
O3TypeFactory & operator=(const O3TypeFactory< GUM_SCALAR > &src)
O3NameSolver< GUM_SCALAR > * _solver_
Definition: O3TypeFactory.h:77