aGrUM  0.14.2
partialInstantiation4MultiDim_tpl.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  ***************************************************************************/
27 // allow partialInstantiationPatterns to be used
28 #define GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED 1
29 
31 
32 #define GUM_MULTI_DIM_DECORATOR_PARTIAL_INST(NAME) \
33  namespace gum { \
34  template < typename GUM_SCALAR > \
35  MultiDimImplementation< GUM_SCALAR >* \
36  NAME(const MultiDimDecorator< GUM_SCALAR >& table, \
37  const HashTable< const DiscreteVariable*, Idx >& inst_vars) { \
38  const MultiDimImplementation< GUM_SCALAR >* impl = table.content(); \
39  return NAME(*impl, inst_vars); \
40  } \
41  }
42 
44 
45 #define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME partialInstantiationMultiDimArray
47 #undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
48 
49 #define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_IMPL2ARRAY_NAME \
50  partialInstantiationMultiDimArray
52 #undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_IMPL2ARRAY_NAME
53 
54 #define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME \
55  partialInstantiationMultiDimArray4Pointers
57 #undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME
58 
59 #define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_IMPL2ARRAY_NAME \
60  partialInstantiationMultiDimArray4Pointers
62 #undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_IMPL2ARRAY_NAME
63 
65 
66 #define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME \
67  partialInstantiationMultiDimImplementation
69 #undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
70 
71 #define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME \
72  partialInstantiationMultiDimImplementation4Pointers
74 #undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
75 
76 // the operators that should be used to select appropriately the functions
77 // to partially instantiate multiDims
78 
80 #define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME partialInstantiation
82 #undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
83 
86 
87 //
88 // DO NOT FORGET TO REGISTER YOUR BINARY FUNCTIONS
89 //
90 
91 namespace gum {
92 
93  // the function used to register all the above functions
94  template < typename GUM_SCALAR >
96  static bool first_init = true;
97 
98  if (first_init) {
99  first_init = false;
100 
101  std::string MultiDimArrayString("MultiDimArray");
102  std::string MultiDimDecisionDiagramString("MultiDimDecisionDiagram");
103  std::string BaseNameString("MultiDimImplementation");
104 
105  // register base functions for multiDimArrays
106  registerPartialInstantiation< GUM_SCALAR >(
107  "i", MultiDimArrayString, &partialInstantiationMultiDimArray);
108 
109  // register default basename functions
110  registerPartialInstantiation< GUM_SCALAR >(
111  "i", BaseNameString, &partialInstantiationMultiDimImplementation);
112  }
113  }
114 
115  // the function used to register all the above functions
116  template < typename GUM_SCALAR >
118  static bool first_init = true;
119 
120  if (first_init) {
121  first_init = false;
122 
123  std::string MultiDimArrayString("MultiDimArray");
124  std::string BaseNameString("MultiDimImplementation");
125 
126  // register base functions for multiDimArrays
127  registerPartialInstantiation< GUM_SCALAR* >(
128  "i", MultiDimArrayString, &partialInstantiationMultiDimArray4Pointers);
129 
130  // register default basename functions
131  registerPartialInstantiation< GUM_SCALAR* >(
132  "i",
133  BaseNameString,
134  &partialInstantiationMultiDimImplementation4Pointers);
135  }
136  }
137 
138 } /* namespace gum */
139 
140 // remove permission to use operatorsPatterns
141 #undef GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED
Headers for PartialInstantiationRegister4MultiDim.
the pattern used by all the partial instantiations of multidimensional tables
the pattern used by all the partial instantiations of multidimensional tables
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
MultiDimArray< GUM_SCALAR *> * partialInstantiationMultiDimArray4Pointers(const MultiDimArray< GUM_SCALAR * > *table, const HashTable< const DiscreteVariable *, Idx > &inst_vars)
A specialized function for instantiating variables in a MultiDimArray.
void pointerPartialInstantiation4MultiDimInit()
The function used to register all the instantiations on multidimImplementations over pointers types...
MultiDimArray< GUM_SCALAR > * partialInstantiationMultiDimArray(const MultiDimArray< GUM_SCALAR > *table, const HashTable< const DiscreteVariable *, Idx > &inst_vars)
A specialized function for instantiating variables in a multiDimArray.
the pattern used by all the partial instantiations of multidimensional tables
MultiDimImplementation< GUM_SCALAR > * partialInstantiation(const MultiDimImplementation< GUM_SCALAR > &table, const HashTable< const DiscreteVariable *, Idx > &inst_vars)
Instantiate variables in a MultiDimImplementation.
void partialInstantiation4MultiDimInit()
The function used to register all the instantiation operators on multidimImplementations over non-poi...
#define GUM_MULTI_DIM_DECORATOR_PARTIAL_INST(NAME)