aGrUM  0.16.0
scheduleCliqueStoreMultiDim_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  NodeProperty< Set< const MultiDimImplementation< GUM_SCALAR >* > >&
41  clique_tables,
42  NodeId clique) :
43  ScheduleOperation< GUM_SCALAR >(
44  ScheduleOperation< GUM_SCALAR >::Type::CLIQUE_STORE_MULTIDIM),
45  __table(table), __tableSet(&clique_tables), __clique(clique), __args(0) {
46  // for debugging purposes
47  GUM_CONSTRUCTOR(ScheduleCliqueStoreMultiDim);
48  }
49 
51  template < typename GUM_SCALAR >
53  const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& from) :
54  ScheduleOperation< GUM_SCALAR >(from),
56  __args(0) {
57  // for debugging purposes
58  GUM_CONS_CPY(ScheduleCliqueStoreMultiDim);
59  }
60 
62  template < typename GUM_SCALAR >
63  ScheduleCliqueStoreMultiDim< GUM_SCALAR >*
65  return new ScheduleCliqueStoreMultiDim< GUM_SCALAR >(*this);
66  }
67 
69  template < typename GUM_SCALAR >
71  // for debugging purposes
72  GUM_DESTRUCTOR(ScheduleCliqueStoreMultiDim);
73 
74  if (__args) delete __args;
75  }
76 
78  template < typename GUM_SCALAR >
79  ScheduleCliqueStoreMultiDim< GUM_SCALAR >&
81  operator=(const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& from) {
82  // avoid self assignment
83  if (&from != this) {
85  __table = from.__table;
86  __tableSet = from.__tableSet;
87  __clique = from.__clique;
88 
89  if (__args) {
90  __args->clear();
91  __args->insert(&__table);
92  }
93  }
94 
95  return *this;
96  }
97 
99  template < typename GUM_SCALAR >
101  operator==(const ScheduleOperation< GUM_SCALAR >& op) const {
102  if (this->type() != op.type()) return false;
103 
104  const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& real_op =
105  static_cast< const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& >(op);
106  return ((__table == real_op.__table) && (__tableSet == real_op.__tableSet)
107  && (__clique == real_op.__clique));
108  }
109 
111  template < typename GUM_SCALAR >
113  operator!=(const ScheduleOperation< GUM_SCALAR >& op) const {
114  if (this->type() != op.type()) return true;
115 
116  const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& real_op =
117  static_cast< const ScheduleCliqueStoreMultiDim< GUM_SCALAR >& >(op);
118  return ((__table != real_op.__table) || (__tableSet != real_op.__tableSet)
119  || (__clique != real_op.__clique));
120  }
121 
123  template < typename GUM_SCALAR >
125  const MultiDimImplementation< GUM_SCALAR >& multidim = __table.multiDim();
126 
127  if (!__tableSet->exists(__clique)) {
128  __tableSet->insert(__clique,
129  Set< const MultiDimImplementation< GUM_SCALAR >* >());
130  }
131 
132  __tableSet->operator[](__clique).insert(&multidim);
133  }
134 
137  template < typename GUM_SCALAR >
139  return 1.0f;
140  }
141 
143  template < typename GUM_SCALAR >
144  INLINE std::pair< long, long >
146  return std::pair< long, long >(0, 0);
147  }
148 
150  template < typename GUM_SCALAR >
151  INLINE const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
153  if (!__args) {
154  __args = new Sequence< const ScheduleMultiDim< GUM_SCALAR >* >;
155  __args->insert(&__table);
156  }
157 
158  return *__args;
159  }
160 
162  template < typename GUM_SCALAR >
163  INLINE const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
165  static Sequence< const ScheduleMultiDim< GUM_SCALAR >* > empty_seq;
166 # ifdef GUM_DEBUG_MODE
167  // for debugging purposes, we should inform the aGrUM's debugger that
168  // the static sequence used here will be removed at the end of the
169  // program's execution.
170  static bool first_time = true;
171 
172  if (first_time) {
173  first_time = false;
174  __debug__::__inc_deletion(
175  "Sequence", __FILE__, __LINE__, "destructor of", (void*)&empty_seq);
176  __debug__::__inc_deletion("SequenceImplementation",
177  __FILE__,
178  __LINE__,
179  "destructor of",
180  (void*)&empty_seq);
181  }
182 
183 # endif /* GUM_DEBUG_MODE */
184  return empty_seq;
185  }
186 
188  template < typename GUM_SCALAR >
190  std::stringstream s;
191  s << "store ( " << __table.toString() << ", clique " << __clique << " )";
192  return s.str();
193  }
194 
195 } /* namespace gum */
196 
197 #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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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:98