GlobalIOList.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) 2015-2017 OpenFOAM Foundation
9 Copyright (C) 2018-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::GlobalIOList
29
30Description
31 IOList with global data (so optionally read from master)
32
33SourceFiles
34 GlobalIOList.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef GlobalIOList_H
39#define GlobalIOList_H
40
41#include "List.H"
42#include "regIOobject.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49/*---------------------------------------------------------------------------*\
50 Class GlobalIOList Declaration
51\*---------------------------------------------------------------------------*/
52
53template<class Type>
54class GlobalIOList
55:
56 public regIOobject,
57 public List<Type>
58{
59public:
61 TypeName("List");
62
63
64 // Constructors
65
66 //- Default copy construct
67 GlobalIOList(const GlobalIOList&) = default;
68
69 //- Construct from IOobject
70 explicit GlobalIOList(const IOobject& io);
71
72 //- Construct from IOobject and zero size (if not read)
74
75 //- Construct from IOobject and list size (if not read)
76 GlobalIOList(const IOobject& io, const label len);
77
78 //- Construct from IOobject and a List
79 GlobalIOList(const IOobject& io, const UList<Type>& content);
80
81 //- Construct by transferring the List content
82 GlobalIOList(const IOobject& io, List<Type>&& content);
83
84
85 //- Destructor
86 virtual ~GlobalIOList() = default;
87
88
89 // Member Functions
90
91 //- Is object global
92 virtual bool global() const
93 {
94 return true;
95 }
96
97 //- Return complete path + object name if the file exists
98 // either in the case/processor or case otherwise null
99 virtual fileName filePath() const
100 {
101 return globalFilePath(type());
102 }
103
104 //- The readData method for regIOobject read operation
105 virtual bool readData(Istream& is);
106
107 //- The writeData method for regIOobject write operation
108 bool writeData(Ostream& os) const;
109
110
111 // Member Operators
112
113 //- Copy assignment of entries
114 void operator=(const GlobalIOList<Type>& rhs);
115
116 //- Copy or move assignment of entries
117 using List<Type>::operator=;
118};
119
120
121// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122
123} // End namespace Foam
124
125// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126
127#ifdef NoRepository
128# include "GlobalIOList.C"
129#endif
130
131// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132
133#endif
134
135// ************************************************************************* //
IOList with global data (so optionally read from master)
Definition: GlobalIOList.H:57
virtual ~GlobalIOList()=default
Destructor.
bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition: GlobalIOList.C:120
virtual bool global() const
Is object global.
Definition: GlobalIOList.H:91
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: GlobalIOList.H:98
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
Definition: GlobalIOList.C:112
GlobalIOList(const GlobalIOList &)=default
Default copy construct.
void operator=(const GlobalIOList< Type > &rhs)
Copy assignment of entries.
Definition: GlobalIOList.C:129
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:593
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
constexpr List() noexcept
Default construct.
Definition: ListI.H:95
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
A class for handling file names.
Definition: fileName.H:76
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73