dune-vtk 2.12
Loading...
Searching...
No Matches
filereader.hh
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <utility>
6
8#include <dune/grid/common/gridfactory.hh>
9
10namespace Dune::Vtk
11{
12 template <class Grid, class FilerReaderImp>
14 {
15 private:
16 // type of underlying implementation, for internal use only
17 using Implementation = FilerReaderImp;
18
20 struct Accessor : public Implementation
21 {
22 template <class... Args>
23 static std::unique_ptr<Grid> createGridFromFileImpl (Args&&... args)
24 {
25 return Implementation::createGridFromFileImpl(std::forward<Args>(args)...);
26 }
27
28 template <class... Args>
29 static void fillFactoryImpl (Args&&... args)
30 {
31 return Implementation::fillFactoryImpl(std::forward<Args>(args)...);
32 }
33 };
34
35 public:
38 template <class... Args>
39 static std::unique_ptr<Grid> createGridFromFile (std::string const& filename, Args&&... args)
40 {
41 return Accessor::createGridFromFileImpl(filename, std::forward<Args>(args)...);
42 }
43
46 template <class... Args>
47 static void fillFactory (GridFactory<Grid>& factory,
48 std::string const& filename,
49 Args&&... args)
50 {
51 Accessor::fillFactoryImpl(factory, filename, std::forward<Args>(args)...);
52 }
53
54 protected: // default implementations
55
56 // Default implementation, redirects to fillFactory implementation.
57 template <class... Args>
59 Args&&... args)
60 {
61 GridFactory<Grid> factory;
62 fillFactory(factory, filename, std::forward<Args>(args)...);
63
64 return std::unique_ptr<Grid>{ factory.createGrid() };
65 }
66
67 // Default implementation for reading into grid-factory: produces a runtime-error.
68 template <class... Args>
69 static void fillFactoryImpl (GridFactory<Grid>& /*factory*/,
70 std::string const& /*filename*/,
71 Args&&... /*args*/)
72 {
74 "GridReader using a factory argument not implemented for concrete reader implementation.");
75 }
76 };
77
78} // end namespace Dune::Vtk
Definition writer.hh:16
#define DUNE_THROW(E,...)
virtual std::unique_ptr< GridType > createGrid()
Definition filereader.hh:14
static void fillFactoryImpl(GridFactory< Grid > &, std::string const &, Args &&...)
Definition filereader.hh:69
static std::unique_ptr< Grid > createGridFromFileImpl(std::string const &filename, Args &&... args)
Definition filereader.hh:58
static void fillFactory(GridFactory< Grid > &factory, std::string const &filename, Args &&... args)
Definition filereader.hh:47
static std::unique_ptr< Grid > createGridFromFile(std::string const &filename, Args &&... args)
Definition filereader.hh:39