threadedCollatedOFstream.C
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) 2020 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 \*---------------------------------------------------------------------------*/
28 
30 #include "decomposedBlockData.H"
31 #include "OFstreamCollator.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 (
38  const fileName& pathName,
39  IOstreamOption streamOpt,
40  const bool useThread
41 )
42 :
43  OStringStream(streamOpt.format(), streamOpt.version()),
44  writer_(writer),
45  pathName_(pathName),
46  compression_(streamOpt.compression()),
47  useThread_(useThread)
48 {}
49 
50 
51 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
52 
54 {
55  writer_.write
56  (
57  decomposedBlockData::typeName,
58  pathName_,
59  str(),
61  version(),
62  compression_,
63  false, // append=false
64  useThread_
65  );
66 }
67 
68 
69 // ************************************************************************* //
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
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::format
streamFormat format() const noexcept
Get the current stream format.
Definition: IOstreamOption.H:289
Foam::OFstreamCollator::write
bool write(const word &typeName, const fileName &, const string &data, IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool append, const bool useThread=true)
Write file with contents. Blocks until writethread has space.
Definition: OFstreamCollator.C:357
Foam::threadedCollatedOFstream::~threadedCollatedOFstream
~threadedCollatedOFstream()
Destructor.
Definition: threadedCollatedOFstream.C:53
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::IOstreamOption::version
versionNumber version() const noexcept
Get the stream version.
Definition: IOstreamOption.H:341
threadedCollatedOFstream.H
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:80
Foam::OFstreamCollator
Threaded file writer.
Definition: OFstreamCollator.H:71
Foam::Detail::StringStreamAllocator< std::ostringstream >::str
Foam::string str() const
Get the string - as Foam::string rather than std::string.
Definition: StringStream.H:91
Foam::IOstreamOption::BINARY
"binary"
Definition: IOstreamOption.H:73
decomposedBlockData.H
Foam::OStringStream
Output to string buffer, using a OSstream.
Definition: StringStream.H:196
Foam::IOstreamOption::compression
compressionType compression() const noexcept
Get the stream compression.
Definition: IOstreamOption.H:315
OFstreamCollator.H