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 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 IOdictionary_H
42 #define 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  //- Destructor
91  virtual ~IOdictionary() = default;
92 
93 
94  // Member Functions
95 
96  //- Is object global
97  virtual bool global() const
98  {
99  return true;
100  }
101 
102  //- Return complete path + object name if the file exists
103  // either in the case/processor or case otherwise null
104  virtual fileName filePath() const
105  {
106  return globalFilePath(type());
107  }
108 };
109 
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 //- Template function for obtaining global status
114 template<>
115 inline bool typeGlobal<IOdictionary>()
116 {
117  return true;
118 }
119 
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 } // End namespace Foam
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #endif
128 
129 // ************************************************************************* //
Foam::IOdictionary::filePath
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: IOdictionary.H:103
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::typeGlobal< IOdictionary >
bool typeGlobal< IOdictionary >()
Template function for obtaining global status.
Definition: IOdictionary.H:114
Foam::IOdictionary::~IOdictionary
virtual ~IOdictionary()=default
Destructor.
baseIOdictionary.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::baseIOdictionary
baseIOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO function...
Definition: baseIOdictionary.H:56
Foam::IOdictionary::IOdictionary
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Definition: IOdictionary.C:37
Foam::IOdictionary::global
virtual bool global() const
Is object global.
Definition: IOdictionary.H:96
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOobject::globalFilePath
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:580
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590