FreeFOAM The Cross-Platform CFD Toolkit
Constant.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::Constant
26 
27 Description
28  Templated basic entry that holds a constant value.
29 
30  Usage - for entry <entryName> having the value <value>:
31  @verbatim
32  <entryName> constant <value>
33  @endverbatim
34 
35 SourceFiles
36  Constant.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Constant_H
41 #define Constant_H
42 
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 template<class Type>
51 class Constant;
52 
53 template<class Type>
54 Ostream& operator<<
55 (
56  Ostream&,
57  const Constant<Type>&
58 );
59 
60 /*---------------------------------------------------------------------------*\
61  Class Constant Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 template<class Type>
65 class Constant
66 :
67  public DataEntry<Type>
68 {
69  // Private data
70 
71  //- Constant value
72  Type value_;
73 
74 
75  // Private Member Functions
76 
77  //- Disallow default bitwise assignment
78  void operator=(const Constant<Type>&);
79 
80 
81 public:
82 
83  // Runtime type information
84  TypeName("constant");
85 
86 
87  // Constructors
88 
89  //- Construct from entry name and Istream
90  Constant(const word& entryName, Istream& is);
91 
92  //- Copy constructor
93  Constant(const Constant<Type>& cnst);
94 
95 
96  //- Destructor
97  virtual ~Constant();
98 
99 
100  // Member Functions
101 
102  //- Return constant value
103  Type value(const scalar) const;
104 
105  //- Integrate between two values
106  Type integrate(const scalar x1, const scalar x2) const;
107 
108 
109  //- Ostream Operator
110  friend Ostream& operator<< <Type>
111  (
112  Ostream&,
113  const Constant<Type>&
114  );
115 };
116 
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 template<>
121 Constant<label>::Constant(const word& entryName, Istream& is);
122 
123 template<>
124 Constant<scalar>::Constant(const word& entryName, Istream& is);
125 
126 
127 } // End namespace Foam
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 #ifdef NoRepository
133 #endif
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 #endif
138 
139 // ************************ vim: set sw=4 sts=4 et: ************************ //