1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 Input inter-processor communications stream operating on external
34 \*---------------------------------------------------------------------------*/
43 #include "PstreamBuffers.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 /*---------------------------------------------------------------------------*\
51 Class UIPstream Declaration
52 \*---------------------------------------------------------------------------*/
63 DynamicList<char>& externalBuf_;
65 label& externalBufPosition_;
69 const bool clearAtEnd_;
74 // Private Member Functions
76 //- Check the bufferPosition against messageSize_ for EOF
77 inline void checkEof();
79 //- Read a T from the transfer buffer
81 inline void readFromBuffer(T&);
83 //- Read data from the transfer buffer
84 inline void readFromBuffer(void* data, size_t count, size_t align);
91 //- Construct given process index to read from and optional buffer size,
92 // read format and IO version
95 const commsTypes commsType,
97 DynamicList<char>& externalBuf,
98 label& externalBufPosition,
99 const int tag = UPstream::msgType(),
100 const bool clearAtEnd = false, // destroy externalBuf if at end
101 streamFormat format=BINARY,
102 versionNumber version=currentVersion
105 //- Construct given buffers
106 UIPstream(const int fromProcNo, PstreamBuffers&);
117 //- Return flags of output stream
118 ios_base::fmtflags flags() const
120 return ios_base::fmtflags(0);
126 //- Read into given buffer from given processor and return the
130 const commsTypes commsType,
131 const int fromProcNo,
133 const std::streamsize bufSize,
134 const int tag = UPstream::msgType()
137 //- Return next token from stream
138 Istream& read(token&);
141 Istream& read(char&);
144 Istream& read(word&);
146 // Read a string (including enclosing double-quotes)
147 Istream& read(string&);
150 Istream& read(label&);
152 //- Read a floatScalar
153 Istream& read(floatScalar&);
155 //- Read a doubleScalar
156 Istream& read(doubleScalar&);
158 //- Read binary block
159 Istream& read(char*, std::streamsize);
161 //- Rewind and return the stream so that it may be read again
167 //- Set flags of stream
168 ios_base::fmtflags flags(const ios_base::fmtflags)
170 return ios_base::fmtflags(0);
176 //- Print description of IOstream to Ostream
177 void print(Ostream&) const;
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 } // End namespace Foam
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 // ************************************************************************* //