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 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::IOMap
29 
30 Description
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 
34 SourceFiles
35  IOMap.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef IOMap_H
40 #define IOMap_H
41 
42 #include "Map.H"
43 #include "regIOobject.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class IOMap Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 template<class T>
55 class IOMap
56 :
57  public regIOobject,
58  public Map<T>
59 {
60 public:
61 
62  //- Runtime type information
63  TypeName("Map");
64 
65 
66  // Constructors
67 
68  //- Default copy construct
69  IOMap(const IOMap&) = default;
70 
71  //- Construct from IOobject
72  explicit IOMap(const IOobject& io);
73 
74  //- Construct from IOobject and size of Map
75  IOMap(const IOobject& io, const label size);
76 
77  //- Construct from IOobject and a copy of Map content
78  IOMap(const IOobject&, const Map<T>& content);
79 
80  //- Construct by transferring the Map content
81  IOMap(const IOobject&, Map<T>&& content);
82 
83 
84  //- Destructor
85  virtual ~IOMap() = default;
86 
87 
88  // Member Functions
89 
90  bool writeData(Ostream& os) const;
91 
92  //- Is object global
93  virtual bool global() const
94  {
95  return true;
96  }
97 
98  //- Return complete path + object name if the file exists
99  // either in the case/processor or case otherwise null
100  virtual fileName filePath() const
101  {
102  return globalFilePath(type());
103  }
104 
105  // Member Operators
106 
107  //- Copy assignment of entries
108  void operator=(const IOMap<T>& rhs);
109 
110  //- Copy or move assignment of entries
111  using Map<T>::operator=;
112 };
113 
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 } // End namespace Foam
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 #ifdef NoRepository
122  #include "IOMap.C"
123 #endif
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #endif
128 
129 // ************************************************************************* //
regIOobject.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::IOMap::global
virtual bool global() const
Is object global.
Definition: IOMap.H:92
Foam::IOMap::operator=
void operator=(const IOMap< T > &rhs)
Copy assignment of entries.
Definition: IOMap.C:146
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
Foam::IOMap::IOMap
IOMap(const IOMap &)=default
Default copy construct.
Foam::IOMap::writeData
bool writeData(Ostream &os) const
Pure virtual writeData function.
Definition: IOMap.C:137
Foam::IOMap::TypeName
TypeName("Map")
Runtime type information.
Map.H
Foam::IOMap::~IOMap
virtual ~IOMap()=default
Destructor.
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
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::IOMap::filePath
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: IOMap.H:99
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
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
IOMap.C
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::IOMap
A Map of objects of type <T> with automated input and output. Is a global object; i....
Definition: IOMap.H:54