dune-vtk 2.12
Loading...
Searching...
No Matches
filereader.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3#pragma once
4
5#include <memory>
6#include <string>
7#include <utility>
8
10#include <dune/grid/common/gridfactory.hh>
11
12namespace Dune::Vtk
13{
14 template <class Grid, class FilerReaderImp>
16 {
17 private:
18 // type of underlying implementation, for internal use only
20
22 struct Accessor : public Implementation
23 {
24 template <class... Args>
25 static std::unique_ptr<Grid> createGridFromFileImpl (Args&&... args)
26 {
27 return Implementation::createGridFromFileImpl(std::forward<Args>(args)...);
28 }
29
30 template <class... Args>
31 static void fillFactoryImpl (Args&&... args)
32 {
33 return Implementation::fillFactoryImpl(std::forward<Args>(args)...);
34 }
35 };
36
37 public:
40 template <class... Args>
42 {
43 return Accessor::createGridFromFileImpl(filename, std::forward<Args>(args)...);
44 }
45
48 template <class... Args>
49 static void fillFactory (GridFactory<Grid>& factory,
50 std::string const& filename,
51 Args&&... args)
52 {
53 Accessor::fillFactoryImpl(factory, filename, std::forward<Args>(args)...);
54 }
55
56 protected: // default implementations
57
58 // Default implementation, redirects to fillFactory implementation.
59 template <class... Args>
61 Args&&... args)
62 {
63 GridFactory<Grid> factory;
64 fillFactory(factory, filename, std::forward<Args>(args)...);
65
66 return std::unique_ptr<Grid>{ factory.createGrid() };
67 }
68
69 // Default implementation for reading into grid-factory: produces a runtime-error.
70 template <class... Args>
71 static void fillFactoryImpl (GridFactory<Grid>& /*factory*/,
72 std::string const& /*filename*/,
73 Args&&... /*args*/)
74 {
76 "GridReader using a factory argument not implemented for concrete reader implementation.");
77 }
78 };
79
80} // end namespace Dune::Vtk
Definition datacollector.hh:19
#define DUNE_THROW(E,...)
Implementation of DataCollector for cells, with continuous data.
Definition celltypedatacollector.hh:20
Definition filereader.hh:16
static void fillFactoryImpl(GridFactory< Grid > &, std::string const &, Args &&...)
Definition filereader.hh:71
static std::unique_ptr< Grid > createGridFromFileImpl(std::string const &filename, Args &&... args)
Definition filereader.hh:60
static void fillFactory(GridFactory< Grid > &factory, std::string const &filename, Args &&... args)
Definition filereader.hh:49
static std::unique_ptr< Grid > createGridFromFile(std::string const &filename, Args &&... args)
Definition filereader.hh:41