TableReader.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::TableReader
26 
27 Description
28  Base class to read table data for tables
29 
30 SourceFiles
31  TableReader.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef TableReader_H
36 #define TableReader_H
37 
38 #include "dictionary.H"
39 #include "fieldTypes.H"
40 #include "runTimeSelectionTables.H"
41 #include "Tuple2.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class TableReader Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 template<class Type>
53 class TableReader
54 {
55 private:
56 
57  // Private Member Functions
58 
59  //- Read a 1D table
60  virtual void read
61  (
62  ISstream&,
64  ) const = 0;
65 
66  //- Read a 2D table
67  virtual void read
68  (
69  ISstream&,
71  ) const = 0;
72 
73 
74 public:
75 
76  //- Runtime type information
77  TypeName("TableReader");
78 
79  // Declare run-time constructor selection table
80 
82  (
83  autoPtr,
85  dictionary,
86  (const dictionary& dict),
87  (dict)
88  );
89 
90 
91  // Constructors
92 
93  //- Construct from dictionary
94  TableReader(const dictionary& dict);
95 
96  //- Construct and return a clone
97  virtual autoPtr<TableReader<Type>> clone() const = 0;
98 
99 
100  // Selector
102  (
103  const word& readerType,
104  const dictionary& dict
105  );
106 
107 
108  //- Destructor
109  virtual ~TableReader();
110 
111 
112  // Member Functions
113 
114  //- Read a table
115  template<class TableType>
116  void operator()(const fileName&, TableType&) const;
117 
118  //- Write additional information
119  virtual void write(Ostream& os) const;
120 };
121 
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 } // End namespace Foam
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 #define defineTableReader(Type) \
130  \
131  defineNamedTemplateTypeNameAndDebug(TableReader<Type>, 0); \
132  \
133  defineTemplateRunTimeSelectionTable(TableReader<Type>, dictionary);
134 
136 #define makeTableReader(SS, Type) \
137  \
138  defineNamedTemplateTypeNameAndDebug(TableReaders::SS<Type>, 0); \
139  \
140  TableReader<Type>::adddictionaryConstructorToTable<TableReaders::SS<Type>> \
141  add##SS##Type##ConstructorToTable_;
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #ifdef NoRepository
146  #include "TableReader.C"
147  #include "FoamTableReader.H"
148 #endif
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #endif
153 
154 // ************************************************************************* //
declareRunTimeSelectionTable(autoPtr, TableReader, dictionary,(const dictionary &dict),(dict))
Base class to read table data for tables.
Definition: TableReader.H:52
dictionary dict
A class for handling file names.
Definition: fileName.H:79
void operator()(const fileName &, TableType &) const
Read a table.
Definition: TableReader.C:81
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Include the header files for all the primitive types that Fields are instantiated for...
A class for handling words, derived from string.
Definition: word.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static autoPtr< TableReader< Type > > New(const word &readerType, const dictionary &dict)
Definition: TableReader.C:33
virtual void write(Ostream &os) const
Write additional information.
Definition: TableReader.C:72
TableReader(const dictionary &dict)
Construct from dictionary.
Definition: TableReader.C:58
Generic input stream.
Definition: ISstream.H:51
virtual autoPtr< TableReader< Type > > clone() const =0
Construct and return a clone.
TypeName("TableReader")
Runtime type information.
virtual ~TableReader()
Destructor.
Definition: TableReader.C:65
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Macros to ease declaration of run-time selection tables.
Namespace for OpenFOAM.