FreeFOAM The Cross-Platform CFD Toolkit
inputModeEntry.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) 1991-2010 OpenCFD Ltd.
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 "inputModeEntry.H"
27 #include <OpenFOAM/dictionary.H>
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 const Foam::word Foam::functionEntries::inputModeEntry::typeName
33 (
34  Foam::functionEntries::inputModeEntry::typeName_()
35 );
36 
37 // Don't lookup the debug switch here as the debug switch dictionary
38 // might include inputModeEntries
39 int Foam::functionEntries::inputModeEntry::debug(0);
40 
41 Foam::functionEntries::inputModeEntry::inputMode
42  Foam::functionEntries::inputModeEntry::mode_(MERGE);
43 
44 namespace Foam
45 {
46 namespace functionEntries
47 {
49  (
50  functionEntry,
51  inputModeEntry,
52  execute,
53  dictionaryIstream
54  );
55 }
56 }
57 
58 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
59 
60 // we could combine this into execute() directly, but leave it here for now
61 void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
62 {
63  clear();
64 
65  word mode(is);
66  if (mode == "merge" || mode == "default")
67  {
68  mode_ = MERGE;
69  }
70  else if (mode == "overwrite")
71  {
72  mode_ = OVERWRITE;
73  }
74  else if (mode == "protect")
75  {
76  mode_ = PROTECT;
77  }
78  else if (mode == "warn")
79  {
80  mode_ = WARN;
81  }
82  else if (mode == "error")
83  {
84  mode_ = ERROR;
85  }
86  else
87  {
88  WarningIn("Foam::functionEntries::inputModeEntry::setMode(Istream&)")
89  << "unsupported input mode '" << mode
90  << "' ... defaulting to 'merge'"
91  << endl;
92  }
93 }
94 
95 
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 
99 (
100  dictionary& parentDict,
101  Istream& is
102 )
103 {
104  setMode(is);
105  return true;
106 }
107 
108 
110 {
111  mode_ = MERGE;
112 }
113 
114 
116 {
117  return mode_ == MERGE;
118 }
119 
120 
122 {
123  return mode_ == OVERWRITE;
124 }
125 
126 
128 {
129  return mode_ == PROTECT;
130 }
131 
133 {
134  return mode_ == ERROR;
135 }
136 
137 
138 // ************************ vim: set sw=4 sts=4 et: ************************ //