stateFunctionObjectTemplates.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2015 OpenFOAM Foundation
9 Copyright (C) 2015-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "IOdictionary.H"
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32
33template<class Type>
35(
36 const word& entryName,
37 const Type& defaultValue
38) const
39{
40 Type result = defaultValue;
41 getProperty(entryName, result);
42 return result;
43}
44
45
46template<class Type>
48(
49 const word& entryName,
50 Type& value
51) const
52{
53 return getObjectProperty(name(), entryName, value);
54}
55
56
57template<class Type>
59(
60 const word& entryName,
61 const Type& value
62)
63{
64 setObjectProperty(name(), entryName, value);
65}
66
67
68template<class Type>
70(
71 const word& objectName,
72 const word& entryName,
73 const Type& defaultValue
74) const
75{
76 Type result = defaultValue;
77 getObjectProperty(objectName, entryName, result);
78 return result;
79}
80
81
82template<class Type>
84(
85 const word& objectName,
86 const word& entryName,
87 Type& value
88) const
89{
90 return stateDict().getObjectProperty(objectName, entryName, value);
91}
92
93
94template<class Type>
96(
97 const word& objectName,
98 const word& entryName,
99 const Type& value
100)
101{
102 stateDict().setObjectProperty(objectName, entryName, value);
103}
104
105
106template<class Type>
108(
109 const word& entryName,
110 const Type& value
111)
112{
113 setObjectResult(name(), entryName, value);
114}
115
116
117template<class Type>
119(
120 const word& objectName,
121 const word& entryName,
122 const Type& value
123)
124{
125 stateDict().setObjectResult(objectName, entryName, value);
126}
127
128
129template<class Type>
131(
132 const word& entryName,
133 const Type& defaultValue
134) const
135{
136 return getObjectResult(name(), entryName, defaultValue);
137}
138
139
140template<class Type>
142(
143 const word& objectName,
144 const word& entryName,
145 const Type& defaultValue
146) const
147{
148 Type result = defaultValue;
149 (void)getObjectResult(objectName, entryName, result);
150 return result;
151}
152
153
154template<class Type>
156(
157 const word& objectName,
158 const word& entryName,
159 Type& value
160) const
161{
162 return stateDict().getObjectResult(objectName, entryName, value);
163}
164
165
166// ************************************************************************* //
void setObjectResult(const word &objectName, const word &entryName, const Type &value)
Add result from named object.
void setResult(const word &entryName, const Type &value)
Add result.
Type getObjectProperty(const word &objectName, const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property from named object.
void setProperty(const word &entryName, const Type &value)
Add generic property.
void setObjectProperty(const word &objectName, const word &entryName, const Type &value)
Add generic property from named object.
Type getProperty(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property.
Type getResult(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve result.
Type getObjectResult(const word &objectName, const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve result from named object.
A class for handling words, derived from Foam::string.
Definition: word.H:68
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59