Loading...
Searching...
No Matches
IOMap.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) 2018-2024 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::IOMap
29
30Description
31 A Map of objects of type <T> with automated input and output.
32 Is a global object; i.e. can be read from undecomposed case.
33
34SourceFiles
35 IOMap.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef Foam_IOMap_H
40#define Foam_IOMap_H
41
42#include "Map.H"
43#include "regIOobject.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class IOMap Declaration
52\*---------------------------------------------------------------------------*/
53
54template<class T>
55class IOMap
56:
57 public regIOobject,
58 public Map<T>
59{
60 // Private Member Functions
61
62 //- Read if IOobject flags set. Return true if read.
63 bool readIOcontents();
64
65public:
66
67 //- The underlying content type
68 typedef Map<T> content_type;
69
70 //- Runtime type information
71 TypeName("Map");
73
74 // Constructors
75
76 //- Default copy construct
77 IOMap(const IOMap&) = default;
78
79 //- Construct from IOobject
80 explicit IOMap(const IOobject& io);
81
82 //- Construct from IOobject and size of Map
83 IOMap(const IOobject& io, const label size);
84
85 //- Construct from IOobject and a copy of Map content
86 IOMap(const IOobject&, const Map<T>& content);
87
88 //- Construct by transferring the Map content
89 IOMap(const IOobject&, Map<T>&& content);
90
91
92 // Factory Methods
93
94 //- Read and return contents. The IOobject will not be registered
95 static Map<T> readContents(const IOobject& io);
96
97
98 //- Destructor
99 virtual ~IOMap() = default;
100
101
102 // Member Functions
103
104 //- This object is 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 {
115 }
116
117 //- The writeData method for regIOobject write operation
118 bool writeData(Ostream& os) const;
119
120
121 // Member Operators
123 //- Copy or move assignment of entries
124 using Map<T>::operator=;
125
126 //- Copy assignment of entries
127 void operator=(const IOMap<T>& rhs)
128 {
130 }
131
132 //- Move assignment of entries
133 void operator=(IOMap<T>&& rhs)
134 {
135 Map<T>::operator=(std::move(static_cast<Map<T>&>(rhs)));
136 }
137};
138
139
140// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141
142//- Global file type for IOMap
143template<class T>
144struct is_globalIOobject<IOMap<T>> : std::true_type {};
145
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149} // End namespace Foam
150
151// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153#ifdef NoRepository
154 #include "IOMap.C"
155#endif
156
157// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158
159#endif
160
161// ************************************************************************* //
friend Ostream & operator(Ostream &, const HashTable< T, label, Hash > &tbl)
A Map of objects of type <T> with automated input and output. Is a global object; i....
Definition IOMap.H:54
void operator=(const IOMap< T > &rhs)
Copy assignment of entries.
Definition IOMap.H:153
virtual ~IOMap()=default
Destructor.
IOMap(const IOMap &)=default
Default copy construct.
bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition IOMap.C:114
virtual bool global() const
This object is global.
Definition IOMap.H:122
void operator=(IOMap< T > &&rhs)
Move assignment of entries.
Definition IOMap.H:161
TypeName("Map")
Runtime type information.
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition IOMap.H:132
Map< T > content_type
The underlying content type.
Definition IOMap.H:67
static Map< T > readContents(const IOobject &io)
Read and return contents. The IOobject will not be registered.
Definition IOMap.C:93
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition IOobject.C:604
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
constexpr Map() noexcept=default
Default construct: empty without allocation (capacity=0).
void operator=(const this_type &rhs)
Copy assignment.
Definition Map.H:152
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A class for handling file names.
Definition fileName.H:75
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition regIOobject.C:43
const volScalarField & T
OBJstream os(runTime.globalPath()/outputName)
const auto & io
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 POSIX.C:801
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Trait for specifying global vs. local IOobject file types.
Definition IOobject.H:175
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68