aGrUM  0.16.0
scheduleSeparatorStoreMultiDim_tpl.h
Go to the documentation of this file.
1 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 
31 # include <agrum/agrum.h>
32 # include <sstream>
33 
34 namespace gum {
35 
37  template < typename GUM_SCALAR >
39  const ScheduleMultiDim< GUM_SCALAR >& table,
40  ArcProperty< Set< const MultiDimImplementation< GUM_SCALAR >* > >&
41  separator_tables,
42  Arc separator) :
43  ScheduleOperation< GUM_SCALAR >(
44  ScheduleOperation< GUM_SCALAR >::Type::SEPARATOR_STORE_MULTIDIM),
45  __table(table), __tableSet(&separator_tables), __separator(separator),
46  __args(0) {
47  // for debugging purposes
48  GUM_CONSTRUCTOR(ScheduleSeparatorStoreMultiDim);
49  }
50 
52  template < typename GUM_SCALAR >
54  const ScheduleSeparatorStoreMultiDim< GUM_SCALAR >& from) :
55  ScheduleOperation< GUM_SCALAR >(from),
56  __table(from.__table), __tableSet(from.__tableSet),
57  __separator(from.__separator), __args(0) {
58  // for debugging purposes
59  GUM_CONS_CPY(ScheduleSeparatorStoreMultiDim);
60  }
61 
63  template < typename GUM_SCALAR >
64  ScheduleSeparatorStoreMultiDim< GUM_SCALAR >*
66  return new ScheduleSeparatorStoreMultiDim< GUM_SCALAR >(*this);
67  }
68 
70  template < typename GUM_SCALAR >
72  // for debugging purposes
73  GUM_DESTRUCTOR(ScheduleSeparatorStoreMultiDim);
74 
75  if (__args) delete __args;
76  }
77 
79  template < typename GUM_SCALAR >
80  ScheduleSeparatorStoreMultiDim< GUM_SCALAR >&
82  operator=(const ScheduleSeparatorStoreMultiDim< GUM_SCALAR >& from) {
83  // avoid self assignment
84  if (&from != this) {
86  __table = from.__table;
87  __tableSet = from.__tableSet;
88  __separator = from.__separator;
89 
90  if (__args) {
91  __args->clear();
92  __args->insert(&__table);
93  }
94  }
95 
96  return *this;
97  }
98 
100  template < typename GUM_SCALAR >
102  operator==(const ScheduleOperation< GUM_SCALAR >& op) const {
103  if (this->type() != op.type()) return false;
104 
105  const ScheduleSeparatorStoreMultiDim< GUM_SCALAR >& real_op =
106  static_cast< const ScheduleSeparatorStoreMultiDim< GUM_SCALAR >& >(op);
107  return ((__table == real_op.__table) && (__tableSet == real_op.__tableSet)
108  && (__separator == real_op.__separator));
109  }
110 
112  template < typename GUM_SCALAR >
114  operator!=(const ScheduleOperation< GUM_SCALAR >& op) const {
115  if (this->type() != op.type()) return true;
116 
117  const ScheduleSeparatorStoreMultiDim< GUM_SCALAR >& real_op =
118  static_cast< const ScheduleSeparatorStoreMultiDim< GUM_SCALAR >& >(op);
119  return ((__table != real_op.__table) || (__tableSet != real_op.__tableSet)
120  || (__separator != real_op.__separator));
121  }
122 
124  template < typename GUM_SCALAR >
126  const MultiDimImplementation< GUM_SCALAR >& multidim = __table.multiDim();
127 
128  if (!__tableSet->exists(__separator)) {
129  __tableSet->insert(__separator,
130  Set< const MultiDimImplementation< GUM_SCALAR >* >());
131  }
132 
133  __tableSet->operator[](__separator).insert(&multidim);
134  }
135 
138  template < typename GUM_SCALAR >
140  return 1.0f;
141  }
142 
144  template < typename GUM_SCALAR >
145  INLINE std::pair< long, long >
147  return std::pair< long, long >(0, 0);
148  }
149 
151  template < typename GUM_SCALAR >
152  INLINE const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
154  if (!__args) {
155  __args = new Sequence< const ScheduleMultiDim< GUM_SCALAR >* >;
156  __args->insert(&__table);
157  }
158 
159  return *__args;
160  }
161 
163  template < typename GUM_SCALAR >
164  INLINE const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
166  static Sequence< const ScheduleMultiDim< GUM_SCALAR >* > empty_seq;
167 # ifdef GUM_DEBUG_MODE
168  // for debugging purposes, we should inform the aGrUM's debugger that
169  // the static sequence used here will be removed at the end of the
170  // program's execution.
171  static bool first_time = true;
172 
173  if (first_time) {
174  first_time = false;
175  __debug__::__inc_deletion(
176  "Sequence", __FILE__, __LINE__, "destructor of", (void*)&empty_seq);
177  __debug__::__inc_deletion("SequenceImplementation",
178  __FILE__,
179  __LINE__,
180  "destructor of",
181  (void*)&empty_seq);
182  }
183 
184 # endif /* [s] */
185  return empty_seq;
186  }
187 
189  template < typename GUM_SCALAR >
191  std::stringstream s;
192  s << "store ( " << __table.toString() << ", separator " << __separator << " )";
193  return s.str();
194  }
195 
196 } /* namespace gum */
197 
198 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
virtual ScheduleSeparatorStoreMultiDim< GUM_SCALAR > * newFactory() const
virtual copy constructor: creates a clone of the operation
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimResults() const
returns the set of multidims that should be the result of the operation
Type type() const
returns the name of the operation
ArcProperty< Set< const MultiDimImplementation< GUM_SCALAR > *> > * __tableSet
std::pair< long, long > memoryUsage() const
returns the memory consumption used during the operation
float nbOperations() const
returns an estimation of the number of elementary operations needed to perform the ScheduleOperation ...
virtual ~ScheduleSeparatorStoreMultiDim()
destructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
bool operator!=(const ScheduleOperation< GUM_SCALAR > &) const
operator !=
bool operator==(const ScheduleOperation< GUM_SCALAR > &) const
operator ==
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimArgs() const
returns the set of multidims passed in argument to the operation
void execute()
executes the operation
ScheduleSeparatorStoreMultiDim< GUM_SCALAR > & operator=(const ScheduleSeparatorStoreMultiDim< GUM_SCALAR > &)
copy operator
std::string toString() const
displays the content of the operation
ScheduleOperation(Type t)
default constructor
ScheduleSeparatorStoreMultiDim(const ScheduleMultiDim< GUM_SCALAR > &table, ArcProperty< Set< const MultiDimImplementation< GUM_SCALAR > * > > &separator_tables, Arc separator)
default constructor
ScheduleOperation< GUM_SCALAR > & operator=(const ScheduleOperation< GUM_SCALAR > &)
copy operator
Sequence< const ScheduleMultiDim< GUM_SCALAR > *> * __args
the set of ScheduleMultidims passed in arguments
HashTable< Arc, VAL > ArcProperty
Property on graph elements.