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 -------------------------------------------------------------------------------
10 License
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 Class
27  Foam::demandDrivenEntry
28 
29 Description
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 
35 SourceFiles
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 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class demandDrivenEntry Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 template<class Type>
57 {
58 private:
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 
75 public:
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 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
demandDrivenEntry.C
Foam::demandDrivenEntry::initialise
void initialise() const
Initialise.
Definition: demandDrivenEntryI.H:33
demandDrivenEntryI.H
Foam::demandDrivenEntry::reset
void reset()
Reset the demand-driven entry.
Definition: demandDrivenEntryI.H:62
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::demandDrivenEntry::setValue
void setValue(const Type &value)
Set the value.
Definition: demandDrivenEntryI.H:53
Foam::demandDrivenEntry
Class for demand-driven dictionary entries.
Definition: demandDrivenEntry.H:55
dictionary.H
Foam::demandDrivenEntry::demandDrivenEntry
demandDrivenEntry(const dictionary &dict, const Type &value)
Constructors.
Definition: demandDrivenEntry.C:34
Foam::demandDrivenEntry::value
const Type & value() const
Return the value.
Definition: demandDrivenEntryI.H:44