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