aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
scheduleStorage.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
47
48#ifndef GUM_SCHEDULE_STORAGE_H
49#define GUM_SCHEDULE_STORAGE_H
50
51#include <string>
52#include <vector>
53
54#include <agrum/agrum.h>
55
59
60#include <type_traits>
61
62namespace gum {
63
64#ifndef DOXYGEN_SHOULD_SKIP_THIS
65
66 namespace ScheduleStorageMethod {
67
70
76 template < typename TABLE, typename CONTAINER_TABLE, template < typename... > class CONTAINER >
77 struct Execution {
78 void execute(TABLE& table, CONTAINER< CONTAINER_TABLE >& container);
79 };
80
82
85 template < typename TABLE >
86 struct Execution< TABLE, TABLE*, Set > {
87 void execute(TABLE& table, Set< TABLE* >& container);
88 };
89
91
94 template < typename TABLE >
95 struct Execution< TABLE, TABLE, std::vector > {
96 void execute(TABLE& table, std::vector< TABLE >& container);
97 };
98
99 } // namespace ScheduleStorageMethod
100
101#endif /* DOXYGEN_SHOULD_SKIP_THIS */
102
109 template < typename TABLE, template < typename... > class CONTAINER >
111 public ScheduleOperator,
112 private ScheduleStorageMethod::
113 Execution< typename std::remove_pointer< TABLE >::type, TABLE, CONTAINER > {
114 public:
115 using SCHED_TABLE = typename std::remove_pointer< TABLE >::type;
116
117
118 // ############################################################################
120 // ############################################################################
122
124
128 explicit ScheduleStorage(const IScheduleMultiDim& table, CONTAINER< TABLE >& container);
129
132
135
138
140 virtual ~ScheduleStorage();
141
143
144
145 // ############################################################################
147 // ############################################################################
149
151 ScheduleStorage< TABLE, CONTAINER >& operator=(const ScheduleStorage< TABLE, CONTAINER >&);
152
154 ScheduleStorage< TABLE, CONTAINER >& operator=(ScheduleStorage< TABLE, CONTAINER >&&);
155
157
161 bool operator==(const ScheduleOperator&) const final;
162
164
168 bool operator!=(const ScheduleOperator&) const final;
169
171
175 virtual bool operator==(const ScheduleStorage< TABLE, CONTAINER >&) const;
176
178
182 virtual bool operator!=(const ScheduleStorage< TABLE, CONTAINER >&) const;
183
185
186
187 // ############################################################################
189 // ############################################################################
191
199 bool hasSameArguments(const ScheduleOperator&) const final;
200
208 bool hasSameArguments(const ScheduleStorage< TABLE, CONTAINER >&) const;
209
213 bool hasSimilarArguments(const ScheduleOperator&) const final;
214
218 bool hasSimilarArguments(const ScheduleStorage< TABLE, CONTAINER >&) const;
219
221 bool isSameOperator(const ScheduleOperator&) const final;
222
224 bool isSameOperator(const ScheduleStorage< TABLE, CONTAINER >&) const;
225
228
230 const Sequence< const IScheduleMultiDim* >& args() const final;
231
233 const Sequence< const IScheduleMultiDim* >& results() const final;
234
236 void execute() final;
237
239 bool isExecuted() const final;
240
242
244 void undo() final;
245
247
253 void updateArgs(const Sequence< const IScheduleMultiDim* >& new_args) final;
254
257 double nbOperations() const final;
258
260
271 std::pair< double, double > memoryUsage() const final;
272
274 std::string toString() const final;
275
277
278
279 private:
282
284
287
289
294
296 CONTAINER< TABLE >* _container_;
297
299 bool _is_executed_{false};
300 };
301
302} /* namespace gum */
303
304// always include the template implementation
306
307#endif /* GUM_SCHEDULE_STORAGE_H */
The Table-agnostic base class of scheduleMultiDim.
a Wrapper for multi-dimensional tables used for scheduling inferences
ScheduleOperator(const ScheduleOperatorType type, const bool imply_deletion, const bool are_results_persistent)
default constructor
void execute() final
really executes the operator
ScheduleStorage< TABLE, CONTAINER > * clone() const final
virtual copy constructor
std::string toString() const final
displays the content of the operator
double nbOperations() const final
returns an estimation of the number of elementary operations needed to perform the ScheduleOperator
const Sequence< const IScheduleMultiDim * > & args() const final
returns the sequence of arguments passed to the operator
std::pair< double, double > memoryUsage() const final
returns the memory consumption used during the execution of the operator
const ScheduleMultiDim< SCHED_TABLE > & arg() const
returns the argument of the storing function
ScheduleStorage(ScheduleStorage< TABLE, CONTAINER > &&from)
move constructor
Sequence< const IScheduleMultiDim * > _args_
the sequence of arguments passed to the operator
void undo() final
undo a previous execution, if any
typename std::remove_pointer< TABLE >::type SCHED_TABLE
bool hasSameArguments(const ScheduleOperator &) const final
checks whether two ScheduleStorage have the same parameters (same variables and same content,...
ScheduleMultiDim< SCHED_TABLE > * _arg_
the table to store
bool isExecuted() const final
indicates whether the operator has been executed
ScheduleStorage(const ScheduleStorage< TABLE, CONTAINER > &from)
copy constructor
ScheduleStorage(const IScheduleMultiDim &table, CONTAINER< TABLE > &container)
default constructor
bool isSameOperator(const ScheduleOperator &) const final
checks whether two ScheduleOperator perform the same operation
bool _is_executed_
indicates whether the operator has been performed or not
const Sequence< const IScheduleMultiDim * > & results() const final
returns the sequence of ScheduleMultidim output by the operator
void updateArgs(const Sequence< const IScheduleMultiDim * > &new_args) final
modifies the arguments of the operator
CONTAINER< TABLE > * _container_
the container into which the table is stored
bool hasSimilarArguments(const ScheduleOperator &) const final
checks whether two ScheduleProjection have similar parameters (same variables but not necessarily the...
Sequence< const IScheduleMultiDim * > _results_
the sequence of ScheduleMultidim output by the operator
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:972
aGrUM's exceptions
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.
a Wrapper for multi-dimensional tables used for scheduling inferences
the base class for "low-level" operators used to schedule inferences
Base class for storing multidimensional tables in scheduling inferences.