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-2023 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"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class TableReader Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 template<class Type>
51 class TableReader
52 {
53 
54 public:
55 
56  //- Runtime type information
57  TypeName("TableReader");
58 
59 
60  // Declare run-time constructor selection table
61 
63  (
64  autoPtr,
66  dictionary,
67  (
68  const word& name,
69  const dictionary& dict,
71  ),
72  (name, dict, table)
73  );
74 
75 
76  // Constructors
77 
78  //- Construct from dictionary
79  TableReader(const dictionary& dict);
80 
81  //- Construct and return a clone
82  virtual autoPtr<TableReader<Type>> clone() const = 0;
83 
84 
85  // Selector
87  (
88  const word& name,
89  const dictionary& dict,
91  );
92 
93 
94  //- Destructor
95  virtual ~TableReader();
96 
97 
98  // Member Functions
99 
100  //- Write additional information
101  virtual void write
102  (
103  Ostream& os,
104  const List<Tuple2<scalar, Type>>& table
105  ) const;
106 };
107 
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 } // End namespace Foam
112 
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 
115 #define defineTableReader(Type) \
116  \
117  defineNamedTemplateTypeNameAndDebug(TableReader<Type>, 0); \
118  \
119  defineTemplateRunTimeSelectionTable(TableReader<Type>, dictionary);
120 
121 
122 #define makeTableReader(SS, Type) \
123  \
124  defineNamedTemplateTypeNameAndDebug(TableReaders::SS<Type>, 0); \
125  \
126  addTemplatedToRunTimeSelectionTable(TableReader, SS, Type, dictionary)
127 
128 #define makeTableReaders(Type) \
129  defineTableReader(Type); \
130  \
131  namespace TableReaders \
132  { \
133  makeTableReader(Embedded, Type); \
134  makeTableReader(Foam, Type); \
135  makeTableReader(Csv, Type); \
136  }
137 
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #ifdef NoRepository
142  #include "TableReader.C"
143  #include "TableReaderNew.C"
144 #endif
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #endif
149 
150 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Base class to read table data for tables.
Definition: TableReader.H:51
declareRunTimeSelectionTable(autoPtr, TableReader, dictionary,(const word &name, const dictionary &dict, List< Tuple2< scalar, Type >> &table),(name, dict, table))
static autoPtr< TableReader< Type > > New(const word &name, const dictionary &dict, List< Tuple2< scalar, Type >> &table)
TypeName("TableReader")
Runtime type information.
virtual void write(Ostream &os, const List< Tuple2< scalar, Type >> &table) const
Write additional information.
Definition: TableReader.C:46
virtual ~TableReader()
Destructor.
Definition: TableReader.C:38
virtual autoPtr< TableReader< Type > > clone() const =0
Construct and return a clone.
TableReader(const dictionary &dict)
Construct from dictionary.
Definition: TableReader.C:31
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:63
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dictionary dict