aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
projectionRegister4MultiDim_tpl.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 A container for registering projection functions on
25  * multiDimImplementations
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/projectionRegister4MultiDim.h>
35 
36 namespace gum {
37 
38  // adds a new entry into the register
39  template < typename GUM_SCALAR >
40  void ProjectionRegister4MultiDim< GUM_SCALAR >::insert(
41  const std::string& projection_name,
42  const std::string& type_multidim,
44  // insert the new entry
46 
49 # ifdef GUM_DEBUG_MODE
50  // for debugging purposes, we should inform the aGrUM's debugger that
51  // the hashtable contained within the ProjectionRegister4MultiDim will be
52  // removed at the end of the program's execution.
53  __debug__::_inc_deletion_("HashTable", __FILE__, __LINE__, "destructor of", (void*)theset);
54 # endif /* GUM_DEBUG_MODE */
55  } else {
57  }
58 
60  }
61 
62  // removes a given entry from the register
63  template < typename GUM_SCALAR >
65  const std::string& type_multidim) {
66  if (!_set_.exists(projection_name)) return;
67 
69 
71  }
72 
73  // indicates whether a given entry exists in the register
74  template < typename GUM_SCALAR >
75  INLINE bool
77  const std::string& type_multidim) const {
78  if (!_set_.exists(projection_name)) return false;
79 
81  }
82 
83  /** @brief returns the specialized operator assigned to a given subtype of
84  * MultiDimImplementation */
85  template < typename GUM_SCALAR >
88  const std::string& type_multidim) const {
90  return theset->operator[](type_multidim);
91  }
92 
93  // a named constructor that constructs one and only one Register per data
94  // type
95  template < typename GUM_SCALAR >
98 
99 # ifdef GUM_DEBUG_MODE
100  static bool first = true;
101 
102  if (first) {
103  first = false;
104  // for debugging purposes, we should inform the aGrUM's debugger that
105  // the hashtable contained within the ProjectionRegister4MultiDim will be
106  // removed at the end of the program's execution.
107  __debug__::_inc_deletion_("HashTable",
108  __FILE__,
109  __LINE__,
110  "destructor of",
111  (void*)&container._set_);
112  }
113 
114 # endif /* GUM_DEBUG_MODE */
115 
116  return container;
117  }
118 
119  // Default constructor: creates an empty register
120  template < typename GUM_SCALAR >
122 
123  // destructor
124  template < typename GUM_SCALAR >
126  // remove all the sets
128  iter != _set_.endSafe();
129  ++iter)
130  delete iter.val();
131  }
132 
133  // a function to more easily register new projection functions in MultiDims
134  template < typename GUM_SCALAR >
135  void registerProjection(
136  const std::string& projection_name,
137  const std::string& type_multidim,
141  function);
142  }
143 
144 } /* namespace gum */
145 
146 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643