FreeFOAM The Cross-Platform CFD Toolkit
DataEntry.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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::DataEntry
26 
27 Description
28  Top level data entry class for use in dictionaries. Provides a mechanism
29  to specify a variable as a certain type, e.g. constant or table, and
30  provide functions to return the (interpolated) value, and integral between
31  limits.
32 
33 SourceFiles
34  DataEntry.C
35  NewDataEntry.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef DataEntry_H
40 #define DataEntry_H
41 
42 #include <OpenFOAM/dictionary.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 template<class Type>
50 class DataEntry;
51 
52 template<class Type>
53 Ostream& operator<<
54 (
55  Ostream&,
56  const DataEntry<Type>&
57 );
58 
59 /*---------------------------------------------------------------------------*\
60  Class DataEntry Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class Type>
64 class DataEntry
65 {
66  // Private Member Functions
67 
68  //- Disallow default bitwise assignment
69  void operator=(const DataEntry<Type>&);
70 
71 
72 protected:
73 
74  // Protected data
75 
76  //- Name of entry
77  const word name_;
78 
79 
80 public:
81 
82  //- Runtime type information
83  TypeName("DataEntry")
84 
85  //- Declare runtime constructor selection table
87  (
88  autoPtr,
90  dictionary,
91  (
92  const word& entryName,
93  Istream& is
94  ),
95  (entryName, is)
96  );
97 
98 
99  // Constructor
100 
101  //- Construct from entry name
102  DataEntry(const word& entryName);
103 
104  //- Copy constructor
105  DataEntry(const DataEntry<Type>& de);
106 
107 
108  //- Selector
109  static autoPtr<DataEntry<Type> > New
110  (
111  const word& entryName,
112  const dictionary& dict
113  );
114 
115 
116  //- Destructor
117  virtual ~DataEntry();
118 
119 
120  // Member Functions
121 
122  // Access
123 
124  //- Return the name of the entry
125  const word& name() const;
126 
127 
128  // Evaluation
129 
130  //- Return value as a function of (scalar) independent variable
131  virtual Type value(const scalar x) const = 0;
132 
133  //- Integrate between two (scalar) values
134  virtual Type integrate(const scalar x1, const scalar x2) const = 0;
135 
136 
137  //- Ostream Operator
138  friend Ostream& operator<< <Type>
139  (
140  Ostream&,
141  const DataEntry<Type>&
142  );
143 };
144 
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 } // End namespace Foam
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #define makeDataEntry(Type) \
153  \
154  defineNamedTemplateTypeNameAndDebug(DataEntry<Type>, 0); \
155  \
156  defineTemplateRunTimeSelectionTable \
157  ( \
158  DataEntry<Type>, \
159  dictionary \
160  );
161 
162 
163 #define makeDataEntryType(SS, Type) \
164  \
165  defineNamedTemplateTypeNameAndDebug(SS<Type>, 0); \
166  \
167  DataEntry<Type>::adddictionaryConstructorToTable<SS<Type> > \
168  add##SS##Type##ConstructorToTable_;
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #ifdef NoRepository
176 #endif
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #endif
181 
182 // ************************ vim: set sw=4 sts=4 et: ************************ //