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

inputModeEntry.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 "inputModeEntry.H"
00028 #include "dictionary.H"
00029 #include "addToMemberFunctionSelectionTable.H"
00030 
00031 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00032 
00033 const Foam::word Foam::functionEntries::inputModeEntry::typeName
00034 (
00035     Foam::functionEntries::inputModeEntry::typeName_()
00036 );
00037 
00038 // Don't lookup the debug switch here as the debug switch dictionary
00039 // might include inputModeEntries
00040 int Foam::functionEntries::inputModeEntry::debug(0);
00041 
00042 Foam::functionEntries::inputModeEntry::inputMode
00043     Foam::functionEntries::inputModeEntry::mode_(MERGE);
00044 
00045 namespace Foam
00046 {
00047 namespace functionEntries
00048 {
00049     addToMemberFunctionSelectionTable
00050     (
00051         functionEntry,
00052         inputModeEntry,
00053         execute,
00054         dictionaryIstream
00055     );
00056 }
00057 }
00058 
00059 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00060 
00061 // we could combine this into execute() directly, but leave it here for now
00062 void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
00063 {
00064     clear();
00065 
00066     word mode(is);
00067     if (mode == "merge" || mode == "default")
00068     {
00069         mode_ = MERGE;
00070     }
00071     else if (mode == "overwrite")
00072     {
00073         mode_ = OVERWRITE;
00074     }
00075     else if (mode == "protect")
00076     {
00077         mode_ = PROTECT;
00078     }
00079     else if (mode == "warn")
00080     {
00081         mode_ = WARN;
00082     }
00083     else if (mode == "error")
00084     {
00085         mode_ = ERROR;
00086     }
00087     else
00088     {
00089         WarningIn("Foam::functionEntries::inputModeEntry::setMode(Istream&)")
00090             << "unsupported input mode '" << mode
00091             << "' ... defaulting to 'merge'"
00092             << endl;
00093     }
00094 }
00095 
00096 
00097 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00098 
00099 bool Foam::functionEntries::inputModeEntry::execute
00100 (
00101     dictionary& parentDict,
00102     Istream& is
00103 )
00104 {
00105     setMode(is);
00106     return true;
00107 }
00108 
00109 
00110 void Foam::functionEntries::inputModeEntry::clear()
00111 {
00112     mode_ = MERGE;
00113 }
00114 
00115 
00116 bool Foam::functionEntries::inputModeEntry::merge()
00117 {
00118     return mode_ == MERGE;
00119 }
00120 
00121 
00122 bool Foam::functionEntries::inputModeEntry::overwrite()
00123 {
00124     return mode_ == OVERWRITE;
00125 }
00126 
00127 
00128 bool Foam::functionEntries::inputModeEntry::protect()
00129 {
00130     return mode_ == PROTECT;
00131 }
00132 
00133 bool Foam::functionEntries::inputModeEntry::error()
00134 {
00135     return mode_ == ERROR;
00136 }
00137 
00138 
00139 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd