![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 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 00062 00063 // Private member functions 00064 00065 //- Read a T from the transfer buffer 00066 template<class T> 00067 inline void readFromBuffer(T&); 00068 00069 //- Read data from the transfer buffer 00070 inline void readFromBuffer(void* data, size_t count); 00071 00072 00073 public: 00074 00075 // Constructors 00076 00077 //- Construct given process index to read from and optional buffer size, 00078 // read format and IO version 00079 IPstream 00080 ( 00081 const int fromProcNo, 00082 const label bufSize = 0, 00083 streamFormat format=BINARY, 00084 versionNumber version=currentVersion 00085 ); 00086 00087 00088 // Destructor 00089 00090 ~IPstream(); 00091 00092 00093 // Member functions 00094 00095 // Inquiry 00096 00097 //- Return flags of output stream 00098 ios_base::fmtflags flags() const 00099 { 00100 return ios_base::fmtflags(0); 00101 } 00102 00103 00104 // Read functions 00105 00106 //- Read into given buffer from given processor 00107 static bool read 00108 ( 00109 const int fromProcNo, 00110 char* buf, 00111 const std::streamsize bufSize 00112 ); 00113 00114 //- Return next token from stream 00115 Istream& read(token&); 00116 00117 //- Read a character 00118 Istream& read(char&); 00119 00120 //- Read a word 00121 Istream& read(word&); 00122 00123 // Read a string (including enclosing double-quotes) 00124 Istream& read(string&); 00125 00126 //- Read a label 00127 Istream& read(label&); 00128 00129 //- Read a floatScalar 00130 Istream& read(floatScalar&); 00131 00132 //- Read a doubleScalar 00133 Istream& read(doubleScalar&); 00134 00135 //- Read binary block 00136 Istream& read(char*, std::streamsize); 00137 00138 //- Rewind and return the stream so that it may be read again 00139 Istream& rewind(); 00140 00141 00142 // Edit 00143 00144 //- Set flags of stream 00145 ios_base::fmtflags flags(const ios_base::fmtflags) 00146 { 00147 return ios_base::fmtflags(0); 00148 } 00149 00150 00151 // Print 00152 00153 //- Print description of IOstream to Ostream 00154 void print(Ostream&) const; 00155 }; 00156 00157 00158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00159 00160 } // End namespace Foam 00161 00162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00163 00164 #endif 00165 00166 // ************************************************************************* //