calcEntry.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-2020 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::functionEntries::calcEntry
26 
27 Description
28  Uses dynamic compilation to provide calculating functionality
29  for entering dictionary entries.
30 
31  E.g.
32 
33  \verbatim
34  a 1.0;
35  b 3;
36  c #calc "$a/$b";
37  \endverbatim
38 
39  Note the explicit trailing 0 ('1.0') to force a to be read (and written)
40  as a floating point number.
41 
42 Note
43  Internally this is just a wrapper around codeStream functionality - the
44  #calc string gets used to construct a dictionary for codeStream.
45 
46 SourceFiles
47  calcEntry.C
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef calcEntry_H
52 #define calcEntry_H
53 
54 #include "functionEntry.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 class dlLibraryTable;
62 
63 namespace functionEntries
64 {
65 
66 /*---------------------------------------------------------------------------*\
67  Class calcEntry Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class calcEntry
71 :
72  public functionEntry
73 {
74  // Private Member Functions
75 
76  //- Perform the calculation and return the resulting string
77  static string calc
78  (
79  const dictionary& dict,
80  Istream& is
81  );
82 
83 
84 public:
85 
86  //- Runtime type information
87  ClassName("calc");
88 
89 
90  // Constructors
91 
92  //- Disallow default bitwise copy construction
93  calcEntry(const calcEntry&) = delete;
94 
95 
96  // Member Functions
97 
98  //- Execute the functionEntry in a sub-dict context
99  static bool execute(dictionary& dict, Istream&);
100 
101  //- Execute the functionEntry in a primitiveEntry context
102  static bool execute
103  (
104  const dictionary& dict,
106  Istream&
107  );
108 
109 
110  // Member Operators
111 
112  //- Disallow default bitwise assignment
113  void operator=(const calcEntry&) = delete;
114 };
115 
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 } // End namespace functionEntries
120 } // End namespace Foam
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 #endif
125 
126 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void operator=(const calcEntry &)=delete
Disallow default bitwise assignment.
Uses dynamic compilation to provide calculating functionality for entering dictionary entries...
Definition: calcEntry.H:69
calcEntry(const calcEntry &)=delete
Disallow default bitwise copy construction.
static bool execute(dictionary &dict, Istream &)
Execute the functionEntry in a sub-dict context.
Definition: calcEntry.C:103
A keyword and a list of tokens is a &#39;primitiveEntry&#39;. An primitiveEntry can be read, written and printed, and the types and values of its tokens analysed.
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:63
const dictionary & dict() const
This entry is not a dictionary,.
ClassName("calc")
Runtime type information.
Namespace for OpenFOAM.