aGrUM  0.14.2
composedLeaf.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
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 // =========================================================================
28 #ifndef GUM_COMPOSED_LEAF_H
29 #define GUM_COMPOSED_LEAF_H
30 // =========================================================================
32 // =========================================================================
33 
34 namespace gum {
35 
45  class ComposedLeaf : public AbstractLeaf {
46  public:
47  // ==========================================================================
49  // ==========================================================================
51 
52  // ###################################################################
54  // ###################################################################
56  AbstractLeaf(leafId), __l1(l1), __l2(l2) {
57  GUM_CONSTRUCTOR(ComposedLeaf);
58  }
59 
60  // ###################################################################
62  // ###################################################################
63  ~ComposedLeaf() { GUM_DESTRUCTOR(ComposedLeaf); }
64 
65  // ============================================================================
67  // ============================================================================
68  void* operator new(size_t s) {
70  }
71  void operator delete(void* p) {
73  }
74 
76 
77  // ###################################################################
79  // ###################################################################
80  double effectif(Idx moda) const {
81  return __l1->effectif(moda) + __l2->effectif(moda);
82  }
83  double total() const { return __l1->total() + __l2->total(); }
84 
85  // ###################################################################
87  // ###################################################################
88  bool contains(NodeId testedId) const {
89  return AbstractLeaf::contains(testedId) || __l1->contains(testedId)
90  || __l2->contains(testedId);
91  }
92 
93  Idx nbModa() const { return __l1->nbModa(); }
94 
95  std::string toString();
96 
97  private:
100  };
101 
102 
103 } /* namespace gum */
104 
105 
106 #endif // GUM_COMPOSED_LEAF_H
virtual bool contains(NodeId testedId) const
Returns true if abstractleaf has leaf in it.
Definition: abstractLeaf.h:90
Idx nbModa() const
Definition: composedLeaf.h:93
virtual double effectif(Idx) const =0
Gaves the leaf effectif for given modality.
Headers of the abstract Leaf class.
double effectif(Idx moda) const
Gaves the leaf effectif for given modality.
Definition: composedLeaf.h:80
AbstractLeaf * __l1
Definition: composedLeaf.h:98
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Definition: abstractLeaf.h:50
std::string toString()
bool contains(NodeId testedId) const
Returns true if abstractleaf has leaf in it.
Definition: composedLeaf.h:88
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
~ComposedLeaf()
Default destructor.
Definition: composedLeaf.h:63
double total() const
Definition: composedLeaf.h:83
virtual Idx nbModa() const =0
ComposedLeaf(NodeId leafId, AbstractLeaf *l1, AbstractLeaf *l2)
Default constructor.
Definition: composedLeaf.h:55
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
<agrum/FMDP/learning/datastructure/leaves/composedLeaf.h>
Definition: composedLeaf.h:45
Size Idx
Type for indexes.
Definition: types.h:50
void * allocate(const size_t &objectSize)
Allocates a block.
static SmallObjectAllocator & instance()
AbstractLeaf * __l2
Definition: composedLeaf.h:99
virtual double total() const =0
Size NodeId
Type for node ids.
Definition: graphElements.h:97