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 -------------------------------------------------------------------------------
11 License
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 
33 template<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 
46 template<class Type>
48 (
49  const word& entryName,
50  Type& value
51 ) const
52 {
53  return getObjectProperty(name(), entryName, value);
54 }
55 
56 
57 template<class Type>
59 (
60  const word& entryName,
61  const Type& value
62 )
63 {
64  setObjectProperty(name(), entryName, value);
65 }
66 
67 
68 template<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 
82 template<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 
94 template<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 
106 template<class Type>
108 (
109  const word& entryName,
110  const Type& value
111 )
112 {
113  setObjectResult(name(), entryName, value);
114 }
115 
116 
117 template<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 
129 template<class Type>
131 (
132  const word& entryName,
133  const Type& defaultValue
134 ) const
135 {
136  return getObjectResult(name(), entryName, defaultValue);
137 }
138 
139 
140 template<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 
154 template<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 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::stateFunctionObject::getProperty
Type getProperty(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property.
Definition: stateFunctionObjectTemplates.C:35
IOdictionary.H
Foam::functionObjects::stateFunctionObject::getObjectResult
Type getObjectResult(const word &objectName, const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve result from named object.
Definition: stateFunctionObjectTemplates.C:142
Foam::functionObjects::stateFunctionObject::setObjectResult
void setObjectResult(const word &objectName, const word &entryName, const Type &value)
Add result from named object.
Definition: stateFunctionObjectTemplates.C:119
Foam::functionObjects::stateFunctionObject::setObjectProperty
void setObjectProperty(const word &objectName, const word &entryName, const Type &value)
Add generic property from named object.
Definition: stateFunctionObjectTemplates.C:96
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::functionObjects::stateFunctionObject::setResult
void setResult(const word &entryName, const Type &value)
Add result.
Definition: stateFunctionObjectTemplates.C:108
Foam::functionObjects::stateFunctionObject::setProperty
void setProperty(const word &entryName, const Type &value)
Add generic property.
Definition: stateFunctionObjectTemplates.C:59
Foam::functionObjects::stateFunctionObject::getResult
Type getResult(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve result.
Definition: stateFunctionObjectTemplates.C:131
Foam::functionObjects::stateFunctionObject::getObjectProperty
Type getObjectProperty(const word &objectName, const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property from named object.
Definition: stateFunctionObjectTemplates.C:70