demandDrivenEntry.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) 2013 OpenFOAM Foundation
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
26Class
27 Foam::demandDrivenEntry
28
29Description
30 Class for demand-driven dictionary entries
31
32 Holds a reference to a dictionary, which is then queried if the value
33 is requested and has not already been cached
34
35SourceFiles
36 demandDrivenEntry.C
37 demandDrivenEntryI.H
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef demandDrivenEntry_H
42#define demandDrivenEntry_H
43
44#include "dictionary.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
50
51/*---------------------------------------------------------------------------*\
52 Class demandDrivenEntry Declaration
53\*---------------------------------------------------------------------------*/
54
55template<class Type>
57{
58private:
59
60 // Private data
61
62 //- Reference to the dictionary
63 const dictionary& dict_;
64
65 //- Keyword to look up
66 const word keyword_;
67
68 //- Value
69 mutable Type value_;
70
71 //- Flag to say that the value has been stored
72 mutable bool stored_;
73
74
75public:
76
77 //- Constructors
78
79 //- Construct from dictionary and value - cannot be re-read
81 (
82 const dictionary& dict,
83 const Type& value
84 );
85
86
87 //- Construct from dictionary and keyword
89 (
90 const dictionary& dict,
91 const word& keyword
92 );
93
94
95 //- Construct from dictionary, keyword and default value
97 (
98 const dictionary& dict,
99 const word& keyword,
100 const Type& defaultValue,
101 const bool readIfPresent = true
102 );
103
104 //- Copy constructor
106
107
108 // Public Member Functions
109
110 //- Initialise
111 inline void initialise() const;
112
113 //- Return the value
114 inline const Type& value() const;
115
116 //- Set the value
117 inline void setValue(const Type& value);
118
119 //- Reset the demand-driven entry
120 inline void reset();
121};
122
123// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124
125} // End namespace Foam
126
127// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128
129#include "demandDrivenEntryI.H"
130
131// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132
133#ifdef NoRepository
134 #include "demandDrivenEntry.C"
135#endif
136
137// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138
139#endif
140
141// ************************************************************************* //
Class for demand-driven dictionary entries.
void initialise() const
Initialise.
void setValue(const Type &value)
Set the value.
const Type & value() const
Return the value.
void reset()
Reset the demand-driven entry.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
dictionary dict
propsDict readIfPresent("fields", acceptFields)