aGrUM  0.14.2
o4DGContext_inl.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 
30 namespace gum {
31 
32  // Set DG1 diagram current explored Node
33  INLINE void O4DGContext::setDG1Node(const NodeId& exploredNode) {
34  __DG1ExploredNode = exploredNode;
35  }
36 
37  // Set DG2 diagram current explored Node
38  INLINE void O4DGContext::setDG2Node(const NodeId& exploredNode) {
39  __DG2ExploredNode = exploredNode;
40  }
41 
42  // Changes given variable modality
43  INLINE void O4DGContext::chgVarModality(Idx varIndex, Idx newModality) {
44  __varInstantiation[varIndex] = newModality;
45  }
46 
47  // Changes given variable modality
48  INLINE Idx O4DGContext::varModality(Idx varIndex) {
49  return __varInstantiation[varIndex];
50  }
51 
52  // Returns o4DGContext key
53  INLINE const double& O4DGContext::key(short int* instNeeded) {
56 
57  for (Idx varPos = 0, offset = __offsetv; varPos < __nbVar; varPos++, offset--)
58  if (instNeeded[varPos])
59  __key += __varInstantiation[varPos] * __logPrime[offset];
60 
61  return __key;
62  }
63 
64  INLINE void* O4DGContext::operator new(size_t s) {
66  }
67 
68  INLINE void O4DGContext::operator delete(void* p) {
70  }
72 
73 
74 } /* end of namespace gum */
static const Idx __offset1
Definition: o4DGContext.h:131
NodeId __DG2ExploredNode
DG2 Diagram current explored node.
Definition: o4DGContext.h:119
static const double __logPrime[]
Table containing the log2 of prime numbers.
Definition: o4DGContext.h:130
double __key
The key use to store the context as a key in the hashtable.
Definition: o4DGContext.h:127
const double & key(short int *instNeeded)
Returns o4DGContext key.
void chgVarModality(Idx, Idx)
Changes given variable modality.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
void setDG1Node(const NodeId &)
Set DG1 diagram current explored Node.
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
void setDG2Node(const NodeId &)
Set DG2 diagram current explored Node.
Size Idx
Type for indexes.
Definition: types.h:50
void * allocate(const size_t &objectSize)
Allocates a block.
Idx * __varInstantiation
Vector containing for each retrograde variable its current modality 0 meaning no instantiation done =...
Definition: o4DGContext.h:123
static SmallObjectAllocator & instance()
Class used to manipulate context during Function Graph Operations.
Definition: o4DGContext.h:46
Class used to manipulate o4DGContext in Function Graph Operations.
static const Idx __offset2
Definition: o4DGContext.h:131
Size NodeId
Type for node ids.
Definition: graphElements.h:97
Idx varModality(Idx)
Changes given variable modality.
NodeId __DG1ExploredNode
DG1 Diagram current explored node.
Definition: o4DGContext.h:116
static const Idx __offsetv
Definition: o4DGContext.h:131