aGrUM  0.14.2
partialInstantiationPattern4MultiDimImplementation.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
29 // check if we allowed these patterns to be used
30 #ifndef GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED
31 
32 // #warning To use partialIntantiationPattern4MultiDimImplementation.h, you must
33 // define GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED
34 
35 #else
36 namespace gum {
37 
38 # ifdef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
39  template < typename GUM_SCALAR >
40  MultiDimImplementation< GUM_SCALAR >* GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME(
41  const MultiDimImplementation< GUM_SCALAR >& ttable,
42  const HashTable< const DiscreteVariable*, Idx >& inst_vars) {
43 # endif
44 
45  typename PartialInstantiationRegister4MultiDim<
46  GUM_SCALAR >::PartialInstantiationPtr func;
47 
48  // get the appropriate function to perform the operation
49  try {
50  // try to find func(ttable,inst_vars) in the register
52  "i", ttable.name());
53  } catch (NotFound&) {
55  "i", ttable.basename());
56  }
57 
58  // perform the partial instantiation
59  return func(&ttable, inst_vars);
60  }
61 
62 } /* End of namespace gum */
63 
64 #endif /* GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED */
static PartialInstantiationRegister4MultiDim & Register()
A named constructor that constructs one and only one Register per data type.
PartialInstantiationPtr get(const std::string &instantiation_func_name, const std::string &type_multidim) const
Returns the specialized partial instantiation operator assigned to a given type of MultiDimImplementa...
#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
a specialized partial instantiation function for multiDimArrays
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25