Flow123d  intersections_paper-476-gbe68821
reader_instances.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file reader_instances.hh
15  * @brief
16  */
17 
18 #ifndef READER_INSTANCES_HH_
19 #define READER_INSTANCES_HH_
20 
21 
22 #include "mesh/msh_gmshreader.h"
23 #include "mesh/mesh.h"
24 #include "system/file_path.hh"
25 
26 #include <memory>
27 
28 
29 /**
30  * Auxiliary class to map filepaths to instances of readers.
31  */
33 public:
34  struct ReaderData {
35  std::shared_ptr<GmshMeshReader> reader_;
36  std::shared_ptr<Mesh> mesh_;
37  };
38 
40 
41  /**
42  * Returns reader of given FilePath.
43  */
44  static std::shared_ptr<GmshMeshReader> get_reader(const FilePath &file_path);
45 
46  /**
47  * Returns mesh of given FilePath.
48  */
49  static std::shared_ptr<Mesh> get_mesh(const FilePath &file_path);
50 
51 private:
52  /// Returns singleton instance
53  static ReaderInstance * instance();
54 
55  /// Constructor
57 
58  /// Returns instance of given FilePath. If reader doesn't exist, creates new ReaderData object.
59  static ReaderData get_instance(const FilePath &file_path);
60 
61  /// Table of readers
62  ReaderTable reader_table_;
63 };
64 
65 
67 public:
69 
70  /// Returns singleton instance
71  static ReaderInstances * instance();
72 
73  /**
74  * Returns mesh reader of get filepath. If reader doesn't exist, creates its.
75  */
76  std::shared_ptr<GmshMeshReader> get_reader(const FilePath &file_path);
77 
78 private:
79  /// Constructor
81 
82  /// Table of readers
83  ReaderTable reader_table_;
84 };
85 
86 
87 #endif /* READER_INSTANCES_HH_ */
std::map< string, std::shared_ptr< GmshMeshReader > > ReaderTable
std::shared_ptr< GmshMeshReader > reader_
std::map< string, ReaderData > ReaderTable
ReaderInstance()
Constructor.
static ReaderData get_instance(const FilePath &file_path)
Returns instance of given FilePath. If reader doesn&#39;t exist, creates new ReaderData object...
ReaderTable reader_table_
Table of readers.
static std::shared_ptr< GmshMeshReader > get_reader(const FilePath &file_path)
static std::shared_ptr< Mesh > get_mesh(const FilePath &file_path)
ReaderInstances()
Constructor.
std::shared_ptr< Mesh > mesh_
Dedicated class for storing path to input and output files.
Definition: file_path.hh:48
static ReaderInstance * instance()
Returns singleton instance.