aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
completeProjectionRegister4MultiDim_tpl.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 A container for registering complete projection functions on
25  * multiDimImplementations, i.e., projections over all variables
26  *
27  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
28  */
29 
30 #ifndef DOXYGEN_SHOULD_SKIP_THIS
31 
32 # include <agrum/agrum.h>
33 
34 # include <agrum/tools/multidim/utils/operators/completeProjectionRegister4MultiDim.h>
35 
36 namespace gum {
37 
38  // adds a new entry into the register
39  template < typename GUM_SCALAR >
40  void CompleteProjectionRegister4MultiDim< GUM_SCALAR >::insert(
41  const std::string& projection_name,
42  const std::string& type_multidim,
45  // insert the new entry
47 
50 # ifdef GUM_DEBUG_MODE
51  // for debugging purposes, we should inform the aGrUM's debugger that
52  // the hashtable contained within the CompleteProjectionRegister4MultiDim
53  // will be removed at the end of the program's execution.
54  __debug__::inc_deletion__("HashTable",
55  __FILE__,
56  __LINE__,
57  "destructor of",
58  (void*)theset);
59 # endif /* GUM_DEBUG_MODE */
60  } else {
62  }
63 
65  }
66 
67  // removes a given entry from the register
68  template < typename GUM_SCALAR >
70  const std::string& projection_name,
71  const std::string& type_multidim) {
72  if (!set__.exists(projection_name)) return;
73 
75 
77  }
78 
79  // indicates whether a given entry exists in the register
80  template < typename GUM_SCALAR >
82  const std::string& projection_name,
83  const std::string& type_multidim) const {
84  if (!set__.exists(projection_name)) return false;
85 
87  }
88 
89  /** @brief returns the specialized operator assigned to a given subtype of
90  * MultiDimImplementation */
91  template < typename GUM_SCALAR >
95  const std::string& projection_name,
96  const std::string& type_multidim) const {
98  return theset-> operator[](type_multidim);
99  }
100 
101  // a named constructor that constructs one and only one Register per data
102  // type
103  template < typename GUM_SCALAR >
107 
108 # ifdef GUM_DEBUG_MODE
109  static bool first = true;
110 
111  if (first) {
112  first = false;
113  // for debugging purposes, we should inform the aGrUM's debugger that
114  // the hashtable contained within the CompleteProjectionRegister4MultiDim
115  // will be removed at the end of the program's execution.
116  __debug__::inc_deletion__("HashTable",
117  __FILE__,
118  __LINE__,
119  "destructor of",
120  (void*)&container.set__);
121  }
122 
123 # endif /* GUM_DEBUG_MODE */
124 
125  return container;
126  }
127 
128  // Default constructor: creates an empty register
129  template < typename GUM_SCALAR >
132 
133  // destructor
134  template < typename GUM_SCALAR >
137  // remove all the sets
139  iter
140  = set__.beginSafe();
141  iter != set__.endSafe();
142  ++iter)
143  delete iter.val();
144  }
145 
146  // a function to more easily register new projection functions in MultiDims
147  template < typename GUM_SCALAR >
148  void
150  const std::string& type_multidim,
156  function);
157  }
158 
159 } /* namespace gum */
160 
161 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669