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-2024 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::GlobalIOList
29 
30 Description
31  IOList with global data (so optionally read from master)
32 
33 SourceFiles
34  GlobalIOList.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_GlobalIOList_H
39 #define Foam_GlobalIOList_H
40 
41 #include "IOList.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class GlobalIOList Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 template<class Type>
53 class GlobalIOList
54 :
55  public regIOobject,
56  public List<Type>
57 {
58 public:
59 
60  //- The underlying content type
61  typedef List<Type> content_type;
62 
63  //- Runtime type information
64  TypeName("List");
65 
66 
67  // Constructors
68 
69  //- Default copy construct
70  GlobalIOList(const GlobalIOList&) = default;
71 
72  //- Construct from IOobject
73  explicit GlobalIOList(const IOobject& io);
74 
75  //- Construct from IOobject and zero size (if not read)
77 
78  //- Construct from IOobject and list size (if not read)
79  GlobalIOList(const IOobject& io, const label len);
80 
81  //- Construct from IOobject and a List
82  GlobalIOList(const IOobject& io, const UList<Type>& content);
83 
84  //- Construct by transferring the List content
85  GlobalIOList(const IOobject& io, List<Type>&& content);
86 
87 
88  // Factory Methods
89 
90  //- Read and return contents. The IOobject is never registered
91  static List<Type> readContents(const IOobject& io);
92 
93 
94  //- Destructor
95  virtual ~GlobalIOList() = default;
96 
97 
98  // Member Functions
99 
100  //- This object is global
101  virtual bool global() const
102  {
103  return true;
104  }
105 
106  //- Return complete path + object name if the file exists
107  //- either in the case/processor or case otherwise null
108  virtual fileName filePath() const
109  {
110  return globalFilePath(type());
111  }
112 
113  //- The readData method for regIOobject read operation
114  virtual bool readData(Istream& is);
115 
116  //- The writeData method for regIOobject write operation
117  bool writeData(Ostream& os) const;
119 
120  // Member Operators
121 
122  //- Copy assignment of entries
123  void operator=(const GlobalIOList<Type>& rhs);
124 
125  //- Copy or move assignment of entries
126  using List<Type>::operator=;
127 };
128 
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 //- Global file type for GlobalIOList
133 template<class T>
134 struct is_globalIOobject<GlobalIOList<T>> : std::true_type {};
135 
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 } // End namespace Foam
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #ifdef NoRepository
144 # include "GlobalIOList.C"
145 #endif
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 #endif
150 
151 // ************************************************************************* //
virtual bool global() const
This object is global.
Definition: GlobalIOList.H:118
GlobalIOList(const GlobalIOList &)=default
Default copy construct.
A class for handling file names.
Definition: fileName.H:72
TypeName("List")
Runtime type information.
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition: IOobject.C:547
void operator=(const GlobalIOList< Type > &rhs)
Copy assignment of entries.
Definition: GlobalIOList.C:143
virtual ~GlobalIOList()=default
Destructor.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
Trait for specifying global vs. local IOobject file types.
Definition: IOobject.H:173
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
Definition: GlobalIOList.C:125
virtual fileName filePath() const
Return complete path + object name if the file exists either in the case/processor or case otherwise ...
Definition: GlobalIOList.H:127
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
OBJstream os(runTime.globalPath()/outputName)
IOList with global data (so optionally read from master)
Definition: GlobalIOList.H:48
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
List< Type > content_type
The underlying content type.
Definition: GlobalIOList.H:58
bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition: GlobalIOList.C:133
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:68
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
static List< Type > readContents(const IOobject &io)
Read and return contents. The IOobject is never registered.
Definition: GlobalIOList.C:105
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
Namespace for OpenFOAM.