Utopia  2
Framework for studying models of complex & adaptive systems.
Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
Utopia::DataIO::TaskFactory< Model, typetag > Class Template Reference

Functor for building a writetask from arguments. More...

#include <factory.hh>

Public Member Functions

template<class SourceGetter , class Getter , class Group_attribute = Nothing, class Dataset_attribute = Nothing>
std::pair< std::string, std::shared_ptr< Default::DefaultWriteTask< Model > > > operator() (std::string name, std::string basegroup_path, DatasetDescriptor dataset_descriptor, SourceGetter &&get_source, Getter &&getter, Group_attribute &&group_attribute=Nothing{}, Dataset_attribute &&dataset_attribute=Nothing{})
 Basic factory function producing Default::DefaultWriteTask<Model> intstances, for writing out data. It is inteded to make the setup of a WriteTask simpler for common cases. More...
 
std::pair< std::string, std::shared_ptr< Default::DefaultWriteTask< Model > > > operator() (std::string name, Default::DefaultBaseGroupBuilder group_builder, Default::DefaultDataWriter< Model > writer, Default::DefaultBuilder< Model > dataset_builder, Default::DefaultAttributeWriterGroup< Model > group_attr, Default::DefaultAttributeWriterDataset< Model > dset_attr)
 Thin wrapper around the writetask constructor which allows to construct a writetask via the factory by providing all the functions the latter employs by hand. This is intended for cases where the other operator() is too restrictive. More...
 

Private Member Functions

template<class Func , class AttributeHandle >
Func _make_attribute_writer (AttributeHandle &&attr)
 Function which produces functions for writing attributes to a dataset or group, and which are used by a writer task to write attributes to the dataset and basegroup it creates. More...
 
Default::DefaultBuilder< Model_make_dataset_builder (DatasetDescriptor dataset_descriptor)
 Function producing a dataset builder function of type Default::DefaultBuilder<Model>, which is responsible for creating new HDF5 datasets on request. More...
 
template<class SourceGetter , class Getter >
Default::DefaultDataWriter< Model_adapt_graph_writer (SourceGetter &&get_source, Getter &&getter)
 Function which adapts getter functions for the correct graph accessor type, i.e., vertex_descriptor etc. More...
 

Static Private Attributes

static std::unordered_map< std::string, std::function< std::string(std::string, Model &) > > _modifiers
 Initialization of the modifier map. More...
 

Detailed Description

template<class Model, TypeTag typetag = TypeTag::plain>
class Utopia::DataIO::TaskFactory< Model, typetag >

Functor for building a writetask from arguments.

Template Parameters
ModelModel type.
TypeTag::plainTypetag, indicates what type of data source is used, has only to be changed when using graphs.

Member Function Documentation

◆ _adapt_graph_writer()

template<class Model , TypeTag typetag = TypeTag::plain>
template<class SourceGetter , class Getter >
Default::DefaultDataWriter< Model > Utopia::DataIO::TaskFactory< Model, typetag >::_adapt_graph_writer ( SourceGetter &&  get_source,
Getter &&  getter 
)
inlineprivate

Function which adapts getter functions for the correct graph accessor type, i.e., vertex_descriptor etc.

Template Parameters
SourceGetterautomatically determined
Getterautomatically determined
Parameters
get_sourceFunction which extracts the source to get data from from its superior structure, e.g., extracting a vertex list from a graph
getterFunction which extracts the data to write from the source, e.g., from the vertex
Returns
Default::DefaultDataWriter< Model >

◆ _make_attribute_writer()

template<class Model , TypeTag typetag = TypeTag::plain>
template<class Func , class AttributeHandle >
Func Utopia::DataIO::TaskFactory< Model, typetag >::_make_attribute_writer ( AttributeHandle &&  attr)
inlineprivate

Function which produces functions for writing attributes to a dataset or group, and which are used by a writer task to write attributes to the dataset and basegroup it creates.

Template Parameters
FuncFunction type to produce
Attributeautomatically determined
Parameters
attrEither 'Nothing' if no attributes shall be written, or a tuple/pair (name, attribute_data) or a function convertible to type Func which takes care of writing dataset attributes, and receives a reference to a model as argument
Returns
Func Function which writes attributes as constructed from arguments.

◆ _make_dataset_builder()

template<class Model , TypeTag typetag = TypeTag::plain>
Default::DefaultBuilder< Model > Utopia::DataIO::TaskFactory< Model, typetag >::_make_dataset_builder ( DatasetDescriptor  dataset_descriptor)
inlineprivate

Function producing a dataset builder function of type Default::DefaultBuilder<Model>, which is responsible for creating new HDF5 datasets on request.

Parameters
dataset_descriptorDescribes dataset properties.
Returns
auto Builder object

◆ operator()() [1/2]

template<class Model , TypeTag typetag = TypeTag::plain>
std::pair< std::string, std::shared_ptr< Default::DefaultWriteTask< Model > > > Utopia::DataIO::TaskFactory< Model, typetag >::operator() ( std::string  name,
Default::DefaultBaseGroupBuilder  group_builder,
Default::DefaultDataWriter< Model writer,
Default::DefaultBuilder< Model dataset_builder,
Default::DefaultAttributeWriterGroup< Model group_attr,
Default::DefaultAttributeWriterDataset< Model dset_attr 
)
inline

Thin wrapper around the writetask constructor which allows to construct a writetask via the factory by providing all the functions the latter employs by hand. This is intended for cases where the other operator() is too restrictive.

Parameters
nameName of the task to be build
group_builderFunction to build a HDFGroup to store datasets in
writerFunction which writes out data
dataset_builderFunction to build Datasets
group_attrFunction writing attributes to the task's base group
dset_attrFunction writing attrbutes to the task's currently active dataset
Returns
std::pair<std::string, Default::DefaultWriteTask<Model>>

◆ operator()() [2/2]

template<class Model , TypeTag typetag = TypeTag::plain>
template<class SourceGetter , class Getter , class Group_attribute = Nothing, class Dataset_attribute = Nothing>
std::pair< std::string, std::shared_ptr< Default::DefaultWriteTask< Model > > > Utopia::DataIO::TaskFactory< Model, typetag >::operator() ( std::string  name,
std::string  basegroup_path,
DatasetDescriptor  dataset_descriptor,
SourceGetter &&  get_source,
Getter &&  getter,
Group_attribute &&  group_attribute = Nothing{},
Dataset_attribute &&  dataset_attribute = Nothing{} 
)
inline

Basic factory function producing Default::DefaultWriteTask<Model> intstances, for writing out data. It is inteded to make the setup of a WriteTask simpler for common cases.

Template Parameters
ModelThe model class the task refers to. The model is the ultimate source of data in utopia context, hence has to be given.
SourceGetterA container type, in this context something which has an iterator, automatically determined.
GetterUnary function type getting SourceGetter::value_type as argument and returning data to be written, automatically determined.
Group_attributeEither callable of type Default::GroupAttributeWriter or a tuplelike object.
Dataset_attributeEither callable of type Default::DatasetAttributeWriter or a tuplelike object.
Parameters
nameString naming this task, to be used with config.
basegroup_pathPath in the HDF5 file to the base_group this task stores its produced datasets in.
get_sourceFunction which returns a container or graph holding the data to use for write
getterUnary function getting a SourceGetter::value_type argument and returning data to be written.
dataset_descriptorDatasetDescriptor instance which gives the properties constructed datasets should have, at the very least its path in the basegroup.
group_attributeEither a callable of type DefaultGroupAttributeWriter or a tuplelike object containing [attribute_name, attribute_data]. Usually, the latter is a descriptive string. The last possiblity is to give 'Nothing', which means that the Attribute should be ignored
dataset_attributeEither a callable of type DefaultGroupAttributeWriter or some a tuplelike object containing [attribute_name, attribute_data]. Usually, the latter is a descriptive string. The last possiblity is to give 'Nothing', which means that the Attribute should be ignored
Returns
std::pair<std::string, Default::DefaultWriteTask<Model>> pair containing a name and a writetask, to be used with the datamanager.

The documentation for this class was generated from the following file: