exprDriverContextI.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29
31{
32 return !contextObjects_.empty();
33}
34
35
36inline const Foam::regIOobject*
38(
39 const word& name
40) const
41{
42 // Like objectRegistry::cfindIOobject()
43 return contextObjects_.lookup(name, nullptr);
44}
45
46
48(
49 const word& name,
50 const regIOobject* objptr
51)
52{
53 if (objptr)
54 {
55 contextObjects_.set(name, objptr);
56 }
57 else
58 {
59 contextObjects_.erase(name);
60 }
61}
62
63
65(
66 const regIOobject* objptr
67)
68{
69 if (objptr)
70 {
71 addContextObject(objptr->name(), objptr);
72 }
73}
74
75
77(
78 const word& name
79)
80{
81 contextObjects_.erase(name);
82}
83
84
86(
87 const regIOobject* objptr
88)
89{
90 if (objptr)
91 {
92 contextObjects_.erase(objptr->name());
93 }
94}
95
96
99{
100 return contextObjects_;
101}
102
103
106{
107 return contextObjects_;
108}
109
110
111template<class ObjType>
112const ObjType*
114{
115 // Like objectRegistry::cfindObject()
116 return dynamic_cast<const ObjType*>(this->cfindContextIOobject(name));
117}
118
119
120// ************************************************************************* //
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
bool empty() const noexcept
True if the hash table is empty.
Definition: HashTableI.H:59
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
void removeContextObject(const word &name)
Remove the object from the context.
bool hasContextObjects() const
True if any context fields are defined.
void addContextObject(const word &name, const regIOobject *)
Add the object to the context.
const ObjType * cfindContextObject(const word &name) const
Find context field object of specified type.
const contextObjectTableType & contextObjects() const noexcept
Read access to the object context.
contextObjectTableType contextObjects_
Externally defined context fields.
Definition: exprDriver.H:208
const regIOobject * cfindContextIOobject(const word &name) const
Find named context field, if it exists.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
A class for handling words, derived from Foam::string.
Definition: word.H:68
const direction noexcept
Definition: Scalar.H:223
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59