fieldDictionary.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::fieldDictionary
28 
29 Description
30  Read field as dictionary (without mesh).
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef fieldDictionary_H
35 #define fieldDictionary_H
36 
37 #include "regIOobject.H"
38 #include "dictionary.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class fieldDictionary Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class fieldDictionary
50 :
51  public regIOobject,
52  public dictionary
53 {
54  const word type_;
55 
56 public:
57 
58  // Redefine type name to be of the instantiated type
59  virtual const word& type() const
60  {
61  return type_;
62  }
63 
64 
65  // Constructors
66 
67  //- Construct from ioobject and overloaded typename.
68  fieldDictionary(const IOobject& io, const word& type)
69  :
70  regIOobject(io),
72  type_(type)
73  {
74  close();
75  }
76 
77 
78 
79  // Member functions
80 
81  bool writeData(Ostream& os) const
82  {
83  static_cast<const dictionary&>(*this).write(os, false);
84 
85  return os.good();
86  }
87 };
88 
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 } // End namespace Foam
93 
94 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 
96 #endif
97 
98 // ************************************************************************* //
regIOobject.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fieldDictionary::fieldDictionary
fieldDictionary(const IOobject &io, const word &type)
Construct from ioobject and overloaded typename.
Definition: fieldDictionary.H:67
Foam::fieldDictionary
Read field as dictionary (without mesh).
Definition: fieldDictionary.H:48
Foam::fieldDictionary::writeData
bool writeData(Ostream &os) const
Pure virtual writeData function.
Definition: fieldDictionary.H:80
Foam::fieldDictionary::type
virtual const word & type() const
Definition: fieldDictionary.H:58
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:67
Foam::regIOobject::close
void close()
Close Istream.
Definition: regIOobjectRead.C:182
Foam::dictionary::write
void write(Ostream &os, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:198
dictionary.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::regIOobject::readStream
Istream & readStream(const word &, const bool valid=true)
Return Istream and check object type against that given.
Definition: regIOobjectRead.C:140
Foam::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:216