aGrUM  0.14.2
scheduleCliqueStoreMultiDim_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  ***************************************************************************/
26 #ifndef DOXYGEN_SHOULD_SKIP_THIS
27 
28 # include <agrum/agrum.h>
29 # include <sstream>
30 
31 namespace gum {
32 
34  template < typename GUM_SCALAR >
36  const ScheduleMultiDim< GUM_SCALAR >& table,
37  NodeProperty< Set< const MultiDimImplementation< GUM_SCALAR >* > >&
38  clique_tables,
39  NodeId clique) :
40  ScheduleOperation< GUM_SCALAR >(
41  ScheduleOperation< GUM_SCALAR >::Type::CLIQUE_STORE_MULTIDIM),
42  __table(table), __tableSet(&clique_tables), __clique(clique), __args(0) {
43  // for debugging purposes
44  GUM_CONSTRUCTOR(ScheduleCliqueStoreMultiDim);
45  }
46 
48  template < typename GUM_SCALAR >
50  const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& from) :
51  ScheduleOperation< GUM_SCALAR >(from),
53  __args(0) {
54  // for debugging purposes
55  GUM_CONS_CPY(ScheduleCliqueStoreMultiDim);
56  }
57 
59  template < typename GUM_SCALAR >
60  ScheduleCliqueStoreMultiDim< GUM_SCALAR >*
62  return new ScheduleCliqueStoreMultiDim< GUM_SCALAR >(*this);
63  }
64 
66  template < typename GUM_SCALAR >
68  // for debugging purposes
69  GUM_DESTRUCTOR(ScheduleCliqueStoreMultiDim);
70 
71  if (__args) delete __args;
72  }
73 
75  template < typename GUM_SCALAR >
76  ScheduleCliqueStoreMultiDim< GUM_SCALAR >&
78  operator=(const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& from) {
79  // avoid self assignment
80  if (&from != this) {
82  __table = from.__table;
83  __tableSet = from.__tableSet;
84  __clique = from.__clique;
85 
86  if (__args) {
87  __args->clear();
88  __args->insert(&__table);
89  }
90  }
91 
92  return *this;
93  }
94 
96  template < typename GUM_SCALAR >
98  operator==(const ScheduleOperation< GUM_SCALAR >& op) const {
99  if (this->type() != op.type()) return false;
100 
101  const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& real_op =
102  static_cast< const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& >(op);
103  return ((__table == real_op.__table) && (__tableSet == real_op.__tableSet)
104  && (__clique == real_op.__clique));
105  }
106 
108  template < typename GUM_SCALAR >
110  operator!=(const ScheduleOperation< GUM_SCALAR >& op) const {
111  if (this->type() != op.type()) return true;
112 
113  const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& real_op =
114  static_cast< const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& >(op);
115  return ((__table != real_op.__table) || (__tableSet != real_op.__tableSet)
116  || (__clique != real_op.__clique));
117  }
118 
120  template < typename GUM_SCALAR >
122  const MultiDimImplementation< GUM_SCALAR >& multidim = __table.multiDim();
123 
124  if (!__tableSet->exists(__clique)) {
125  __tableSet->insert(__clique,
126  Set< const MultiDimImplementation< GUM_SCALAR >* >());
127  }
128 
129  __tableSet->operator[](__clique).insert(&multidim);
130  }
131 
134  template < typename GUM_SCALAR >
136  return 1.0f;
137  }
138 
140  template < typename GUM_SCALAR >
141  INLINE std::pair< long, long >
143  return std::pair< long, long >(0, 0);
144  }
145 
147  template < typename GUM_SCALAR >
148  INLINE const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
150  if (!__args) {
151  __args = new Sequence< const ScheduleMultiDim< GUM_SCALAR >* >;
152  __args->insert(&__table);
153  }
154 
155  return *__args;
156  }
157 
159  template < typename GUM_SCALAR >
160  INLINE const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
162  static Sequence< const ScheduleMultiDim< GUM_SCALAR >* > empty_seq;
163 # ifdef GUM_DEBUG_MODE
164  // for debugging purposes, we should inform the aGrUM's debugger that
165  // the static sequence used here will be removed at the end of the
166  // program's execution.
167  static bool first_time = true;
168 
169  if (first_time) {
170  first_time = false;
171  __debug__::__inc_deletion(
172  "Sequence", __FILE__, __LINE__, "destructor of", (void*)&empty_seq);
173  __debug__::__inc_deletion("SequenceImplementation",
174  __FILE__,
175  __LINE__,
176  "destructor of",
177  (void*)&empty_seq);
178  }
179 
180 # endif /* GUM_DEBUG_MODE */
181  return empty_seq;
182  }
183 
185  template < typename GUM_SCALAR >
187  std::stringstream s;
188  s << "store ( " << __table.toString() << ", clique " << __clique << " )";
189  return s.str();
190  }
191 
192 } /* namespace gum */
193 
194 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
bool operator!=(const ScheduleOperation< GUM_SCALAR > &) const
operator !=
ScheduleCliqueStoreMultiDim(const ScheduleMultiDim< GUM_SCALAR > &table, NodeProperty< Set< const MultiDimImplementation< GUM_SCALAR > * > > &clique_tables, NodeId clique)
default constructor
Type type() const
returns the name of the operation
bool operator==(const ScheduleOperation< GUM_SCALAR > &) const
operator ==
std::pair< long, long > memoryUsage() const
returns the memory consumption used during the operation
void execute()
executes the operation
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Sequence< const ScheduleMultiDim< GUM_SCALAR > *> * __args
the set of ScheduleMultidims passed in arguments
virtual ~ScheduleCliqueStoreMultiDim()
destructor
NodeProperty< Set< const MultiDimImplementation< GUM_SCALAR > *> > * __tableSet
float nbOperations() const
returns an estimation of the number of elementary operations needed to perform the ScheduleOperation ...
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimArgs() const
returns the set of multidims passed in argument to the operation
virtual ScheduleCliqueStoreMultiDim< GUM_SCALAR > * newFactory() const
virtual copy constructor: creates a clone of the operation
ScheduleOperation(Type t)
default constructor
ScheduleCliqueStoreMultiDim< GUM_SCALAR > & operator=(const ScheduleCliqueStoreMultiDim< GUM_SCALAR > &)
copy operator
ScheduleMultiDim< GUM_SCALAR > __table
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimResults() const
returns the set of multidims that should be the result of the operation
ScheduleOperation< GUM_SCALAR > & operator=(const ScheduleOperation< GUM_SCALAR > &)
copy operator
std::string toString() const
displays the content of the operation
Size NodeId
Type for node ids.
Definition: graphElements.h:97