OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

functionEntry.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "functionEntry.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033     defineMemberFunctionSelectionTable
00034     (
00035         functionEntry,
00036         execute,
00037         dictionaryIstream
00038     );
00039 
00040     defineMemberFunctionSelectionTable
00041     (
00042         functionEntry,
00043         execute,
00044         primitiveEntryIstream
00045     );
00046 }
00047 
00048 
00049 // * * * * * * * * * * * * Member Function Selectors * * * * * * * * * * * * //
00050 
00051 bool Foam::functionEntry::execute
00052 (
00053     const word& functionName,
00054     dictionary& parentDict,
00055     Istream& is
00056 )
00057 {
00058     is.fatalCheck
00059     (
00060         "functionEntry::execute"
00061         "(const word& functionName, dictionary& parentDict, Istream&)"
00062     );
00063 
00064     if (!executedictionaryIstreamMemberFunctionTablePtr_)
00065     {
00066         cerr<<"functionEntry::execute"
00067             << "(const word&, dictionary&, Istream&)"
00068             << " not yet initialized, function = "
00069             << functionName.c_str() << std::endl;
00070 
00071         // Return true to keep reading
00072         return true;
00073     }
00074 
00075     executedictionaryIstreamMemberFunctionTable::iterator mfIter =
00076         executedictionaryIstreamMemberFunctionTablePtr_->find(functionName);
00077 
00078     if (mfIter == executedictionaryIstreamMemberFunctionTablePtr_->end())
00079     {
00080         FatalErrorIn
00081         (
00082             "functionEntry::execute"
00083             "(const word& functionName, dictionary& parentDict, Istream&)"
00084         )   << "Unknown functionEntry " << functionName
00085             << endl << endl
00086             << "Valid functionEntries are :" << endl
00087             << executedictionaryIstreamMemberFunctionTablePtr_->toc()
00088             << exit(FatalError);
00089     }
00090 
00091     return mfIter()(parentDict, is);
00092 }
00093 
00094 
00095 bool Foam::functionEntry::execute
00096 (
00097     const word& functionName,
00098     const dictionary& parentDict,
00099     primitiveEntry& entry,
00100     Istream& is
00101 )
00102 {
00103     is.fatalCheck
00104     (
00105         "functionEntry::execute"
00106         "(const word&, const dictionary&, primitiveEntry&, Istream&)"
00107     );
00108 
00109     if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_)
00110     {
00111         cerr<<"functionEntry::execute"
00112             << "(const word&, const dictionary&, primitiveEntry&, Istream&)"
00113             << " not yet initialized, function = "
00114             << functionName.c_str() << std::endl;
00115 
00116         // return true to keep reading anyhow
00117         return true;
00118     }
00119 
00120     executeprimitiveEntryIstreamMemberFunctionTable::iterator mfIter =
00121         executeprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName);
00122 
00123     if (mfIter == executeprimitiveEntryIstreamMemberFunctionTablePtr_->end())
00124     {
00125         FatalErrorIn
00126         (
00127             "functionEntry::execute"
00128             "(const word&, const dictionary&, primitiveEntry&, Istream&)"
00129         )   << "Unknown functionEntry " << functionName
00130             << endl << endl
00131             << "Valid functionEntries are :" << endl
00132             << executeprimitiveEntryIstreamMemberFunctionTablePtr_->toc()
00133             << exit(FatalError);
00134     }
00135 
00136     return mfIter()(parentDict, entry, is);
00137 }
00138 
00139 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd