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 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 GlobalIOList_H
39 #define GlobalIOList_H
40 
41 #include "List.H"
42 #include "regIOobject.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class GlobalIOList Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Type>
54 class GlobalIOList
55 :
56  public regIOobject,
57  public List<Type>
58 {
59 public:
60 
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
73  GlobalIOList(const IOobject& io, const label size);
74 
75  //- Construct from IOobject and a List
76  GlobalIOList(const IOobject& io, const UList<Type>& content);
77 
78  //- Construct by transferring the List content
79  GlobalIOList(const IOobject& io, List<Type>&& content);
80 
81 
82  //- Destructor
83  virtual ~GlobalIOList() = default;
84 
85 
86  // Member Functions
87 
88  //- Is object global
89  virtual bool global() const
90  {
91  return true;
92  }
93 
94  //- Return complete path + object name if the file exists
95  // either in the case/processor or case otherwise null
96  virtual fileName filePath() const
97  {
98  return globalFilePath(type());
99  }
100 
101  //- The readData method for regIOobject read operation
102  virtual bool readData(Istream& is);
103 
104  //- The writeData method for regIOobject write operation
105  bool writeData(Ostream& os) const;
106 
107 
108  // Member Operators
109 
110  //- Copy assignment of entries
111  void operator=(const GlobalIOList<Type>& rhs);
112 
113  //- Copy or move assignment of entries
114  using List<Type>::operator=;
115 };
116 
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 } // End namespace Foam
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 #ifdef NoRepository
125 # include "GlobalIOList.C"
126 #endif
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
regIOobject.H
Foam::GlobalIOList::TypeName
TypeName("List")
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
List.H
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
GlobalIOList.C
Foam::GlobalIOList::writeData
bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition: GlobalIOList.C:108
Foam::GlobalIOList::readData
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
Definition: GlobalIOList.C:100
Foam::GlobalIOList::GlobalIOList
GlobalIOList(const GlobalIOList &)=default
Default copy construct.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::GlobalIOList::global
virtual bool global() const
Is object global.
Definition: GlobalIOList.H:88
Foam::GlobalIOList::operator=
void operator=(const GlobalIOList< Type > &rhs)
Copy assignment of entries.
Definition: GlobalIOList.C:117
Foam::GlobalIOList::filePath
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: GlobalIOList.H:95
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
os
OBJstream os(runTime.globalPath()/outputName)
Foam::GlobalIOList::~GlobalIOList
virtual ~GlobalIOList()=default
Destructor.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
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
Foam::UList< Type >
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GlobalIOList
IOList with global data (so optionally read from master)
Definition: GlobalIOList.H:53