IOdictionary.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
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 Class
25  Foam::IOdictionary
26 
27 Description
28  IOdictionary is derived from dictionary and IOobject to give the
29  dictionary automatic IO functionality via the objectRegistry. To facilitate
30  IO, IOdictionary is provided with a constructor from IOobject and writeData
31  and write functions.
32 
33 SourceFiles
34  IOdictionary.C
35  IOdictionaryIO.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef IOdictionary_H
40 #define IOdictionary_H
41 
42 #include "dictionary.H"
43 #include "regIOobject.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class IOdictionary Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class IOdictionary
55 :
56  public regIOobject,
57  public dictionary
58 {
59 
60 protected:
61 
62  // Protected constructors
63 
64  //- Construct given an IOobject, supply wanted typeName
65  IOdictionary(const IOobject& io, const word& wantedType);
66 
67 
68 public:
69 
70  TypeName("dictionary");
71 
72 
73  // Public static data
74 
75  static bool writeDictionaries;
76 
77 
78  // Constructors
79 
80  //- Construct given an IOobject
81  IOdictionary(const IOobject&);
82 
83  //- Construct given an IOobject and dictionary
84  IOdictionary(const IOobject&, const dictionary&);
85 
86  //- Construct given an IOobject and Istream
87  IOdictionary(const IOobject&, Istream&);
88 
89  //- Copy constructor
90  IOdictionary(const IOdictionary&);
91 
92  //- Move constructor
94 
95 
96  //- Destructor
97  virtual ~IOdictionary();
98 
99 
100  // Member Functions
101 
102  using regIOobject::name;
103 
104  //- Is object global
105  virtual bool global() const
106  {
107  return true;
108  }
109 
110  //- Return complete path + object name if the file exists
111  // either in the case/processor or case otherwise null
112  virtual fileName filePath() const
113  {
114  return globalFilePath(type());
115  }
116 
117  //- ReadData function required for regIOobject read operation
118  virtual bool readData(Istream&);
119 
120  //- WriteData function required for regIOobject write operation
121  virtual bool writeData(Ostream&) const;
122 
123 
124  // Member Operators
125 
126  //- Assignment of dictionary entries only
127  void operator=(const IOdictionary&);
128 
129  //- Move assignment of dictionary entries only
130  void operator=(IOdictionary&&);
131 };
132 
133 
134 //- Template function for obtaining global status
135 template<>
136 inline bool typeGlobal<IOdictionary>()
137 {
138  return true;
139 }
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #endif
149 
150 // ************************************************************************* //
static bool writeDictionaries
Definition: IOdictionary.H:74
const word & name() const
Return name.
Definition: IOobject.H:303
A class for handling file names.
Definition: fileName.H:79
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual bool global() const
Is object global.
Definition: IOdictionary.H:104
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
void operator=(const IOdictionary &)
Assignment of dictionary entries only.
Definition: IOdictionary.C:137
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: IOdictionary.H:111
A class for handling words, derived from string.
Definition: word.H:59
fileName globalFilePath(const word &typeName) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:392
virtual ~IOdictionary()
Destructor.
Definition: IOdictionary.C:131
IOdictionary(const IOobject &io, const word &wantedType)
Construct given an IOobject, supply wanted typeName.
Definition: IOdictionary.C:47
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
bool typeGlobal< IOdictionary >()
Template function for obtaining global status.
Definition: IOdictionary.H:135
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
TypeName("dictionary")
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.