IOdictionary.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-2017 OpenFOAM Foundation
9  Copyright (C) 2021-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::IOdictionary
29 
30 Description
31  IOdictionary is derived from dictionary and IOobject to give the dictionary
32  automatic IO functionality via the objectRegistry. To facilitate IO,
33  IOdictionary is provided with a constructor from IOobject and with
34  readData/writeData functions.
35 
36 SourceFiles
37  IOdictionary.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_IOdictionary_H
42 #define Foam_IOdictionary_H
43 
44 #include "baseIOdictionary.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class IOdictionary Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class IOdictionary
56 :
57  public baseIOdictionary
58 {
59 public:
60 
61  // Constructors
62 
63  //- Construct given an IOobject
64  //- and optional fallback dictionary content
65  // A null dictionary pointer is treated like an empty dictionary.
66  explicit IOdictionary
67  (
68  const IOobject& io,
69  const dictionary* fallback = nullptr
70  );
71 
72  //- Construct given an IOobject
73  //- and fallback dictionary content
74  IOdictionary(const IOobject& io, const dictionary& dict);
75 
76  //- Construct given an IOobject, wanted typeName
77  //- and optional fallback dictionary content
78  // A null dictionary pointer is treated like an empty dictionary.
80  (
81  const IOobject& io,
82  const word& wantedType,
83  const dictionary* fallback = nullptr
84  );
85 
86  //- Construct given an IOobject and Istream
87  IOdictionary(const IOobject& io, Istream& is);
88 
89 
90  // Factory Methods
91 
92  //- Read and return contents. The IOobject will not be registered
93  static dictionary readContents(const IOobject& io);
94 
95 
96  //- Destructor
97  virtual ~IOdictionary() = default;
98 
99 
100  // Member Functions
101 
102  //- Is object global
103  virtual bool global() const
104  {
105  return true;
106  }
107 
108  //- Return complete path + object name if the file exists
109  // either in the case/processor or case otherwise null
110  virtual fileName filePath() const
111  {
112  return globalFilePath(type());
113  }
114 };
115 
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 //- Global file type for IOdictionary
120 template<>
121 struct is_globalIOobject<IOdictionary> : std::true_type {};
122 
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 } // End namespace Foam
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
virtual ~IOdictionary()=default
Destructor.
dictionary dict
A class for handling file names.
Definition: fileName.H:72
baseIOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO function...
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition: IOobject.C:547
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
Definition: IOdictionary.C:30
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual bool global() const
Is object global.
Definition: IOdictionary.H:114
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Trait for specifying global vs. local file types.
Definition: IOobject.H:981
static dictionary readContents(const IOobject &io)
Read and return contents. The IOobject will not be registered.
Definition: IOdictionary.C:89
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: IOdictionary.H:124
A class for handling words, derived from Foam::string.
Definition: word.H:63
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Namespace for OpenFOAM.