Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
write_task.hh
Go to the documentation of this file.
1#ifndef UTOPIA_DATAIO_DATA_MANAGER_WRITE_TASK_HH
2#define UTOPIA_DATAIO_DATA_MANAGER_WRITE_TASK_HH
3
4// metaprogramming
5#include "../../core/metaprogramming.hh"
6#include "../../core/type_traits.hh"
7
8// for hdf5 support
9#include "../hdfdataset.hh"
10#include "../hdfgroup.hh"
11
12namespace Utopia
13{
14namespace DataIO
15{
16
48template < class BGB, class DW, class DB, class AWG, class AWD >
49struct WriteTask final // inheriting from this thing is useless, hence can be final
50{
52 using Writer = DW;
53 using Builder = DB;
56
61
65 std::shared_ptr< HDFGroup > base_group;
66
70 std::shared_ptr< HDFDataset> active_dataset;
71
76
81
86
92
98 std::string
100 {
101 if (active_dataset != nullptr)
102 {
103 return active_dataset->get_path();
104 }
105 else
106 {
107 return "";
108 }
109 }
110
116 std::string
118 {
119 if (base_group != nullptr)
120 {
121 return base_group->get_path();
122 }
123 else
124 {
125 return "";
126 }
127 }
128
134 void
136 {
137 if (this == &other)
138 {
139 return;
140 }
141 else
142 {
143 using std::swap;
144 swap(build_basegroup, other.build_basegroup);
145 swap(base_group, other.base_group);
146 swap(active_dataset, other.active_dataset);
147 swap(write_data, other.write_data);
148 swap(build_dataset, other.build_dataset);
150 other.write_attribute_active_dataset);
151 swap(write_attribute_basegroup, other.write_attribute_basegroup);
152 }
153 }
154
169 template < typename Basegroupbuilder,
170 typename Writertype,
171 typename Buildertype,
172 typename AWritertypeG,
173 typename AWritertypeD >
185
189 WriteTask() = default;
190
197 WriteTask(const WriteTask& other) = default;
198
205
212 WriteTask&
213 operator=(const WriteTask& other) = default;
214
221 WriteTask&
223
227 ~WriteTask() = default;
228};
229
238template < class BGB, class DW, class DB, class AWG, class AWD >
239void
245
246// Deduction guide for WriteTask
247template < typename Basegroupbuilder,
248 typename Writertype,
249 typename Buildertype,
250 typename AWritertypeG,
251 typename AWritertypeD >
253 Writertype&& w,
254 Buildertype&& b,
257 ->WriteTask< std::decay_t< Basegroupbuilder >,
258 std::decay_t< Writertype >,
259 std::decay_t< Buildertype >,
260 std::decay_t< AWritertypeG >,
261 std::decay_t< AWritertypeD > >;
262
267} // namespace DataIO
268} // namespace Utopia
269
270#endif
void swap(WriteTask< BGB, DW, DB, AWG, AWD > &lhs, WriteTask< BGB, DW, DB, AWG, AWD > &rhs)
Swaps the state of lhs and rhs.
Definition write_task.hh:240
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
Definition agent.hh:11
Encapsulate a task for writing data to a destination. Containes a callable 'writer' responisible for ...
Definition write_task.hh:50
WriteTask(const WriteTask &other)=default
Writer write_data
Callable to write data.
Definition write_task.hh:75
WriteTask & operator=(WriteTask &&other)=default
Move assign from 'other'.
WriteTask & operator=(const WriteTask &other)=default
Copy assign caller from 'other'.
WriteTask()=default
Construct a new writer Task object.
std::shared_ptr< HDFDataset > active_dataset
pointer to the dataset which is currently active
Definition write_task.hh:70
std::string get_base_path()
Get the path to the base group object.
Definition write_task.hh:117
AWD AttributeWriterDataset
Definition write_task.hh:55
BasegroupBuilder build_basegroup
Function building a base group.
Definition write_task.hh:60
WriteTask(WriteTask &&other)=default
Construct a new writer Task object.
AWG AttributeWriterGroup
Definition write_task.hh:54
WriteTask(Basegroupbuilder &&bgb, Writertype &&w, Buildertype &&b, AWritertypeG &&ag, AWritertypeD &&ad)
Construct a new Write Task object.
Definition write_task.hh:174
Builder build_dataset
Callable to build new dataset.
Definition write_task.hh:80
std::string get_active_path()
Get the path of active dataset relative to the base_group.
Definition write_task.hh:99
void swap(WriteTask &other)
Swap the state of the caller with 'other'.
Definition write_task.hh:135
BGB BasegroupBuilder
Definition write_task.hh:51
std::shared_ptr< HDFGroup > base_group
pointer to the hdfgroup in which all produced datasets live.
Definition write_task.hh:65
AttributeWriterDataset write_attribute_active_dataset
Callable to write attributes to dataset; invoked after task write.
Definition write_task.hh:85
~WriteTask()=default
Destroy the writer Task object.
DB Builder
Definition write_task.hh:53
DW Writer
Definition write_task.hh:52
AttributeWriterGroup write_attribute_basegroup
Callabel to write attributes to base group, invoked after task build.
Definition write_task.hh:91