threadedCollatedOFstream.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) 2017-2018 OpenFOAM Foundation
9  Copyright (C) 2021 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::threadedCollatedOFstream
29 
30 Description
31  Master-only drop-in replacement for OFstream.
32 
33 SourceFiles
34  threadedCollatedOFstream.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef threadedCollatedOFstream_H
39 #define threadedCollatedOFstream_H
40 
41 #include "dictionary.H"
42 #include "StringStream.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 class OFstreamCollator;
51 
52 /*---------------------------------------------------------------------------*\
53  Class threadedCollatedOFstream Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  public OStringStream
59 {
60  // Private Data
61 
62  //- The backend writer
63  OFstreamCollator& writer_;
64 
65  const fileName pathName_;
66 
67  const IOstreamOption::compressionType compression_;
68 
69  const bool useThread_;
70 
71  //- Additional FoamFile entries for decomposed data
72  dictionary headerEntries_;
73 
74 
75 public:
76 
77  // Constructors
78 
79  //- Construct and set stream status
81  (
83  const fileName& pathname,
84  IOstreamOption streamOpt = IOstreamOption(),
85  const bool useThread = true
86  );
87 
88 
89  //- Destructor
91 
92 
93  // Member Functions
94 
95  //- Define the header entries for the data block(s)
96  void setHeaderEntries(const dictionary& dict);
97 
98 
99  // Additional constructors and methods (as per v2012 and earlier)
100  #ifdef Foam_IOstream_extras
101 
102  //- Construct and set stream status
104  (
106  const fileName& pathname,
110  const bool useThread = true
111  )
112  :
114  (
115  writer,
116  pathname,
117  IOstreamOption(fmt, ver, cmp),
118  useThread
119  )
120  {}
121 
122  #endif /* Foam_IOstream_extras */
123 };
124 
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 } // End namespace Foam
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #endif
133 
134 // ************************************************************************* //
Foam::IOstreamOption::UNCOMPRESSED
compression = false
Definition: IOstreamOption.H:79
Foam::threadedCollatedOFstream::setHeaderEntries
void setHeaderEntries(const dictionary &dict)
Define the header entries for the data block(s)
Definition: threadedCollatedOFstream.C:71
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::IOstreamOption::IOstreamOption
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Definition: IOstreamOption.H:193
Foam::threadedCollatedOFstream::threadedCollatedOFstream
threadedCollatedOFstream(OFstreamCollator &writer, const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool useThread=true)
Construct and set stream status.
Definition: threadedCollatedOFstream.C:36
Foam::IOstreamOption::currentVersion
static const versionNumber currentVersion
The current version number (2.0)
Definition: IOstreamOption.H:165
StringStream.H
Input/output from string buffers.
Foam::threadedCollatedOFstream::~threadedCollatedOFstream
~threadedCollatedOFstream()
Destructor.
Definition: threadedCollatedOFstream.C:54
Foam::IOstreamOption::versionNumber
Representation of a major/minor version number.
Definition: IOstreamOption.H:85
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:70
Foam::threadedCollatedOFstream
Master-only drop-in replacement for OFstream.
Definition: threadedCollatedOFstream.H:55
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:81
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::OFstreamCollator
Threaded file writer.
Definition: OFstreamCollator.H:70
Foam::OStringStream
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Definition: StringStream.H:227
dictionary.H
Foam::IOstreamOption::compressionType
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
Definition: IOstreamOption.H:77