FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/functionEntry.H>
00027 
00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032     defineMemberFunctionSelectionTable
00033     (
00034         functionEntry,
00035         execute,
00036         dictionaryIstream
00037     );
00038 
00039     defineMemberFunctionSelectionTable
00040     (
00041         functionEntry,
00042         execute,
00043         primitiveEntryIstream
00044     );
00045 }
00046 
00047 
00048 // * * * * * * * * * * * * Member Function Selectors * * * * * * * * * * * * //
00049 
00050 bool Foam::functionEntry::execute
00051 (
00052     const word& functionName,
00053     dictionary& parentDict,
00054     Istream& is
00055 )
00056 {
00057     is.fatalCheck
00058     (
00059         "functionEntry::execute"
00060         "(const word& functionName, dictionary& parentDict, Istream&)"
00061     );
00062 
00063     if (!executedictionaryIstreamMemberFunctionTablePtr_)
00064     {
00065         cerr<<"functionEntry::execute"
00066             << "(const word&, dictionary&, Istream&)"
00067             << " not yet initialized, function = "
00068             << functionName.c_str() << std::endl;
00069 
00070         // Return true to keep reading
00071         return true;
00072     }
00073 
00074     executedictionaryIstreamMemberFunctionTable::iterator mfIter =
00075         executedictionaryIstreamMemberFunctionTablePtr_->find(functionName);
00076 
00077     if (mfIter == executedictionaryIstreamMemberFunctionTablePtr_->end())
00078     {
00079         FatalErrorIn
00080         (
00081             "functionEntry::execute"
00082             "(const word& functionName, dictionary& parentDict, Istream&)"
00083         )   << "Unknown functionEntry '" << functionName
00084             << "' in " << is.name() << " near line " << is.lineNumber()
00085             << endl << endl
00086             << "Valid functionEntries are :" << endl
00087             << executedictionaryIstreamMemberFunctionTablePtr_->sortedToc()
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             << "' in " << is.name() << " near line " << is.lineNumber()
00131             << endl << endl
00132             << "Valid functionEntries are :" << endl
00133             << executeprimitiveEntryIstreamMemberFunctionTablePtr_->sortedToc()
00134             << exit(FatalError);
00135     }
00136 
00137     return mfIter()(parentDict, entry, is);
00138 }
00139 
00140 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines