aGrUM  0.16.0
scheduleDeleteMultiDim_tpl.h
Go to the documentation of this file.
1 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 
31 # include <agrum/agrum.h>
32 # include <limits>
33 
34 // to ease ide parser
36 
37 namespace gum {
38 
40  template < typename GUM_SCALAR >
42  const ScheduleMultiDim< GUM_SCALAR >& table) :
43  ScheduleOperation< GUM_SCALAR >(
44  ScheduleOperation< GUM_SCALAR >::Type::DELETE_MULTIDIM),
45  __table(table), __args(0) {
46  // for debugging purposes
47  GUM_CONSTRUCTOR(ScheduleDeleteMultiDim);
48  }
49 
51  template < typename GUM_SCALAR >
53  const ScheduleDeleteMultiDim< GUM_SCALAR >& from) :
54  ScheduleOperation< GUM_SCALAR >(from),
55  __table(from.__table), __args(0) {
56  // for debugging purposes
57  GUM_CONS_CPY(ScheduleDeleteMultiDim);
58  }
59 
61  template < typename GUM_SCALAR >
62  ScheduleDeleteMultiDim< GUM_SCALAR >*
64  return new ScheduleDeleteMultiDim< GUM_SCALAR >(*this);
65  }
66 
68  template < typename GUM_SCALAR >
70  // for debugging purposes
71  GUM_DESTRUCTOR(ScheduleDeleteMultiDim);
72 
73  if (__args) delete __args;
74  }
75 
77  template < typename GUM_SCALAR >
78  ScheduleDeleteMultiDim< GUM_SCALAR >& ScheduleDeleteMultiDim< GUM_SCALAR >::
79  operator=(const ScheduleDeleteMultiDim< GUM_SCALAR >& from) {
80  // avoid self assignment
81  if (&from != this) {
83  __table = from.__table;
84 
85  if (__args) {
86  __args->clear();
87  __args->insert(&__table);
88  }
89  }
90 
91  return *this;
92  }
93 
95  template < typename GUM_SCALAR >
97  operator==(const ScheduleOperation< GUM_SCALAR >& op) const {
98  if (this->type() != op.type()) return false;
99 
100  const ScheduleDeleteMultiDim< GUM_SCALAR >& real_op =
101  static_cast< const ScheduleDeleteMultiDim< GUM_SCALAR >& >(op);
102  return __table == real_op.__table;
103  }
104 
106  template < typename GUM_SCALAR >
108  operator!=(const ScheduleOperation< GUM_SCALAR >& op) const {
109  if (this->type() != op.type()) return true;
110 
111  const ScheduleDeleteMultiDim< GUM_SCALAR >& real_op =
112  static_cast< const ScheduleDeleteMultiDim< GUM_SCALAR >& >(op);
113  return __table != real_op.__table;
114  }
115 
117  template < typename GUM_SCALAR >
119  const MultiDimImplementation< GUM_SCALAR >& multidim = __table.multiDim();
122  delete &multidim;
123  }
124 
127  template < typename GUM_SCALAR >
129  return 1.0f;
130  }
131 
133  template < typename GUM_SCALAR >
134  INLINE std::pair< long, long >
136  long size_table = long(__table.domainSize());
137 
138  if (size_table < 0) {
139  GUM_ERROR(OutOfBounds, "memory usage out of long int range");
140  }
141 
142  return std::pair< long, long >(-size_table, -size_table);
143  }
144 
146  template < typename GUM_SCALAR >
147  INLINE const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
149  if (!__args) {
150  __args = new Sequence< const ScheduleMultiDim< GUM_SCALAR >* >;
151  __args->insert(&__table);
152  }
153 
154  return *__args;
155  }
156 
158  template < typename GUM_SCALAR >
159  INLINE const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
161  static Sequence< const ScheduleMultiDim< GUM_SCALAR >* > empty_seq;
162 # ifdef GUM_DEBUG_MODE
163  // for debugging purposes, we should inform the aGrUM's debugger that
164  // the static sequence used here will be removed at the end of the
165  // program's execution.
166  static bool first_time = true;
167 
168  if (first_time) {
169  first_time = false;
170  __debug__::__inc_deletion(
171  "Sequence", __FILE__, __LINE__, "destructor of", (void*)&empty_seq);
172  __debug__::__inc_deletion("SequenceImplementation",
173  __FILE__,
174  __LINE__,
175  "destructor of",
176  (void*)&empty_seq);
177  __debug__::__inc_deletion(
178  "HashTable", __FILE__, __LINE__, "destructor of", (void*)&empty_seq);
179  __debug__::__inc_deletion("SequenceIteratorSafe",
180  __FILE__,
181  __LINE__,
182  "destructor of",
183  (void*)&empty_seq);
184  __debug__::__inc_deletion("SequenceIteratorSafe",
185  __FILE__,
186  __LINE__,
187  "destructor of",
188  (void*)&empty_seq);
189  }
190 
191 # endif /* GUM_DEBUG_MODE */
192  return empty_seq;
193  }
194 
196  template < typename GUM_SCALAR >
198  return "delete ( " + __table.toString() + " )";
199  }
200 
201 } // namespace gum
202 
203 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
static HashTable< const MultiDimImplementation< GUM_SCALAR > *, Idx > & __multidim2id()
returns the id corresponding to a given multidim
std::string toString() const
displays the content of the operation
Type type() const
returns the name of the operation
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimResults() const
returns the set of multidims that should be the result of the operation
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
std::pair< long, long > memoryUsage() const
returns the memory consumption used during the operation
virtual ~ScheduleDeleteMultiDim()
destructor
ScheduleDeleteMultiDim(const ScheduleMultiDim< GUM_SCALAR > &table)
default constructor
void execute()
executes the operation
ScheduleOperation(Type t)
default constructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
ScheduleMultiDim< GUM_SCALAR > __table
ScheduleOperation< GUM_SCALAR > & operator=(const ScheduleOperation< GUM_SCALAR > &)
copy operator
float nbOperations() const
returns an estimation of the number of elementary operations needed to perform the ScheduleOperation ...
ScheduleDeleteMultiDim< GUM_SCALAR > & operator=(const ScheduleDeleteMultiDim< GUM_SCALAR > &)
copy operator
static HashTable< Idx, const MultiDimImplementation< GUM_SCALAR > *> & __id2multidim()
returns a mapping from id to multidimImplementations
virtual ScheduleDeleteMultiDim< GUM_SCALAR > * newFactory() const
virtual copy constructor: creates a clone of the operation
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimArgs() const
returns the set of multidims passed in argument to the operation
bool operator==(const ScheduleOperation< GUM_SCALAR > &) const
operator ==
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
bool operator!=(const ScheduleOperation< GUM_SCALAR > &) const
operator !=
Sequence< const ScheduleMultiDim< GUM_SCALAR > *> * __args
the set of ScheduleMultidims passed in arguments