functionEntry.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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "functionEntry.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
33  (
34  functionEntry,
35  execute,
36  dictionaryIstream
37  );
38 
40  (
41  functionEntry,
42  execute,
43  primitiveEntryIstream
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * Member Function Selectors * * * * * * * * * * * * //
49 
51 (
52  const word& functionName,
53  dictionary& parentDict,
54  Istream& is
55 )
56 {
57  is.fatalCheck
58  (
59  "functionEntry::execute"
60  "(const word& functionName, dictionary& parentDict, Istream&)"
61  );
62 
63  if (!executedictionaryIstreamMemberFunctionTablePtr_)
64  {
65  cerr<< "functionEntry::execute"
66  << "(const word&, dictionary&, Istream&)"
67  << " not yet initialized, function = "
68  << functionName.c_str() << std::endl;
69 
70  // Return true to keep reading
71  return true;
72  }
73 
74  executedictionaryIstreamMemberFunctionTable::iterator mfIter =
75  executedictionaryIstreamMemberFunctionTablePtr_->find(functionName);
76 
77  if (mfIter == executedictionaryIstreamMemberFunctionTablePtr_->end())
78  {
80  (
81  "functionEntry::execute"
82  "(const word& functionName, dictionary& parentDict, Istream&)"
83  ) << "Unknown functionEntry '" << functionName
84  << "' in " << is.name() << " near line " << is.lineNumber()
85  << nl << nl
86  << "Valid functionEntries are :" << endl
87  << executedictionaryIstreamMemberFunctionTablePtr_->toc()
88  << exit(FatalError);
89  }
90 
91  return mfIter()(parentDict, is);
92 }
93 
94 
96 (
97  const word& functionName,
98  const dictionary& parentDict,
99  primitiveEntry& entry,
100  Istream& is
101 )
102 {
103  is.fatalCheck
104  (
105  "functionEntry::execute"
106  "(const word&, const dictionary&, primitiveEntry&, Istream&)"
107  );
108 
109  if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_)
110  {
111  cerr<< "functionEntry::execute"
112  << "(const word&, const dictionary&, primitiveEntry&, Istream&)"
113  << " not yet initialized, function = "
114  << functionName.c_str() << std::endl;
115 
116  // return true to keep reading anyhow
117  return true;
118  }
119 
120  executeprimitiveEntryIstreamMemberFunctionTable::iterator mfIter =
121  executeprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName);
122 
123  if (mfIter == executeprimitiveEntryIstreamMemberFunctionTablePtr_->end())
124  {
126  (
127  "functionEntry::execute"
128  "(const word&, const dictionary&, primitiveEntry&, Istream&)"
129  ) << "Unknown functionEntry '" << functionName
130  << "' in " << is.name() << " near line " << is.lineNumber()
131  << nl << nl
132  << "Valid functionEntries are :" << endl
133  << executeprimitiveEntryIstreamMemberFunctionTablePtr_->toc()
134  << exit(FatalError);
135  }
136 
137  return mfIter()(parentDict, entry, is);
138 }
139 
140 
141 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A class for handling words, derived from string.
Definition: word.H:59
static bool execute(const word &functionName, dictionary &parentDict, Istream &)
Execute the functionEntry in a sub-dict context.
Definition: functionEntry.C:51
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
defineMemberFunctionSelectionTable(edgeMesh, write, fileExtension)
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:107
label lineNumber() const
Return current stream line number.
Definition: IOstream.H:438
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
virtual const fileName & name() const
Return the name of the stream.
Definition: IOstream.H:297
error FatalError
A keyword and a list of tokens is a &#39;primitiveEntry&#39;. An primitiveEntry can be read, written and printed, and the types and values of its tokens analysed.