|
|
|
IPstream.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 IPstream 00027 00028 Description 00029 Input inter-processor communications stream. 00030 00031 SourceFiles 00032 IPstream.C 00033 IPread.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #include "Pstream.H" 00038 00039 #ifndef IPstream_H 00040 #define IPstream_H 00041 00042 #include "Istream.H" 00043 00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00045 00046 namespace Foam 00047 { 00048 00049 /*---------------------------------------------------------------------------*\ 00050 Class IPstream Declaration 00051 \*---------------------------------------------------------------------------*/ 00052 00053 class IPstream 00054 : 00055 public Pstream, 00056 public Istream 00057 { 00058 // Private data 00059 00060 int fromProcNo_; 00061 label messageSize_; 00062 00063 // Private member functions 00064 00065 //- Check the bufferPosition_ against messageSize_ for EOF 00066 inline void checkEof(); 00067 00068 //- Read a T from the transfer buffer 00069 template<class T> 00070 inline void readFromBuffer(T&); 00071 00072 //- Read data from the transfer buffer 00073 inline void readFromBuffer(void* data, size_t count); 00074 00075 00076 public: 00077 00078 // Constructors 00079 00080 //- Construct given process index to read from and optional buffer size, 00081 // read format and IO version 00082 IPstream 00083 ( 00084 const int fromProcNo, 00085 const label bufSize = 0, 00086 streamFormat format=BINARY, 00087 versionNumber version=currentVersion 00088 ); 00089 00090 00091 // Destructor 00092 00093 ~IPstream(); 00094 00095 00096 // Member functions 00097 00098 // Inquiry 00099 00100 //- Return flags of output stream 00101 ios_base::fmtflags flags() const 00102 { 00103 return ios_base::fmtflags(0); 00104 } 00105 00106 00107 // Read functions 00108 00109 //- Read into given buffer from given processor and return the 00110 // message size 00111 static label read 00112 ( 00113 const int fromProcNo, 00114 char* buf, 00115 const std::streamsize bufSize 00116 ); 00117 00118 //- Return next token from stream 00119 Istream& read(token&); 00120 00121 //- Read a character 00122 Istream& read(char&); 00123 00124 //- Read a word 00125 Istream& read(word&); 00126 00127 // Read a string (including enclosing double-quotes) 00128 Istream& read(string&); 00129 00130 //- Read a label 00131 Istream& read(label&); 00132 00133 //- Read a floatScalar 00134 Istream& read(floatScalar&); 00135 00136 //- Read a doubleScalar 00137 Istream& read(doubleScalar&); 00138 00139 //- Read binary block 00140 Istream& read(char*, std::streamsize); 00141 00142 //- Rewind and return the stream so that it may be read again 00143 Istream& rewind(); 00144 00145 00146 // Edit 00147 00148 //- Set flags of stream 00149 ios_base::fmtflags flags(const ios_base::fmtflags) 00150 { 00151 return ios_base::fmtflags(0); 00152 } 00153 00154 00155 // Print 00156 00157 //- Print description of IOstream to Ostream 00158 void print(Ostream&) const; 00159 }; 00160 00161 00162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00163 00164 } // End namespace Foam 00165 00166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00167 00168 #endif 00169 00170 // ************************************************************************* // |