aGrUM  0.17.2
a C++ library for (probabilistic) graphical models
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 >&
80  const ScheduleDeleteMultiDim< GUM_SCALAR >& from) {
81  // avoid self assignment
82  if (&from != this) {
84  __table = from.__table;
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  const ScheduleOperation< GUM_SCALAR >& op) const {
99  if (this->type() != op.type()) return false;
100 
101  const ScheduleDeleteMultiDim< GUM_SCALAR >& real_op =
102  static_cast< const ScheduleDeleteMultiDim< GUM_SCALAR >& >(op);
103  return __table == real_op.__table;
104  }
105 
107  template < typename GUM_SCALAR >
109  const ScheduleOperation< GUM_SCALAR >& op) const {
110  if (this->type() != op.type()) return true;
111 
112  const ScheduleDeleteMultiDim< GUM_SCALAR >& real_op =
113  static_cast< const ScheduleDeleteMultiDim< GUM_SCALAR >& >(op);
114  return __table != real_op.__table;
115  }
116 
118  template < typename GUM_SCALAR >
120  const MultiDimImplementation< GUM_SCALAR >& multidim = __table.multiDim();
123  delete &multidim;
124  }
125 
128  template < typename GUM_SCALAR >
130  return 1.0f;
131  }
132 
134  template < typename GUM_SCALAR >
135  INLINE std::pair< long, long >
137  long size_table = long(__table.domainSize());
138 
139  if (size_table < 0) {
140  GUM_ERROR(OutOfBounds, "memory usage out of long int range");
141  }
142 
143  return std::pair< long, long >(-size_table, -size_table);
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  __debug__::__inc_deletion(
179  "HashTable", __FILE__, __LINE__, "destructor of", (void*)&empty_seq);
180  __debug__::__inc_deletion("SequenceIteratorSafe",
181  __FILE__,
182  __LINE__,
183  "destructor of",
184  (void*)&empty_seq);
185  __debug__::__inc_deletion("SequenceIteratorSafe",
186  __FILE__,
187  __LINE__,
188  "destructor of",
189  (void*)&empty_seq);
190  }
191 
192 # endif /* GUM_DEBUG_MODE */
193  return empty_seq;
194  }
195 
197  template < typename GUM_SCALAR >
199  return "delete ( " + __table.toString() + " )";
200  }
201 
202 } // namespace gum
203 
204 #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-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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