FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

IPstreamImpl.H

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------*\
00002                 ______                _     ____          __  __
00003                |  ____|             _| |_  / __ \   /\   |  \/  |
00004                | |__ _ __ ___  ___ /     \| |  | | /  \  | \  / |
00005                |  __| '__/ _ \/ _ ( (| |) ) |  | |/ /\ \ | |\/| |
00006                | |  | | |  __/  __/\_   _/| |__| / ____ \| |  | |
00007                |_|  |_|  \___|\___|  |_|   \____/_/    \_\_|  |_|
00008 
00009                     FreeFOAM: The Cross-Platform CFD Toolkit
00010 
00011   Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
00012                           Gerber van der Graaf <gerber_graaf@users.sf.net>
00013 --------------------------------------------------------------------------------
00014 License
00015     This file is part of FreeFOAM.
00016 
00017     FreeFOAM is free software: you can redistribute it and/or modify it
00018     under the terms of the GNU General Public License as published by the
00019     Free Software Foundation, either version 3 of the License, or (at your
00020     option) any later version.
00021 
00022     FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
00023     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00024     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00025     for more details.
00026 
00027     You should have received a copy of the GNU General Public License
00028     along with FreeFOAM.  If not, see <http://www.gnu.org/licenses/>.
00029 
00030 Class
00031     Foam::IPstreamImpl
00032 
00033 Description
00034     Abstract base class for IPstream operations that depend on the parallel
00035     library used. Foam::IPstreamImpl::New will lookup the entry
00036     "PstreamImplementation" in the global controlDict file (i.e. the one
00037     found by Foam::dotFoam) and tries to first load a library named
00038     lib<PstreamImplementation>Pstream.so, and then instantiate the class
00039     <PstreamImplementation>IPstreamImpl.
00040 
00041 SourceFiles
00042     IPstreamImpl.C
00043 
00044 
00045 \*----------------------------------------------------------------------------*/
00046 
00047 #ifndef IPstreamImpl_H
00048 #define IPstreamImpl_H
00049 
00050 #include <OpenFOAM/PstreamImpl.H>
00051 #include <OpenFOAM/autoPtr.H>
00052 #include <OpenFOAM/typeInfo.H>
00053 #include <OpenFOAM/runTimeSelectionTables.H>
00054 
00055 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00056 
00057 namespace Foam
00058 {
00059 
00060 /*---------------------------------------------------------------------------*\
00061                            Class IPstreamImpl Declaration
00062 \*---------------------------------------------------------------------------*/
00063 
00064 class IPstreamImpl
00065 {
00066     // Private data
00067 
00068         //- The singleton instance
00069         static autoPtr<IPstreamImpl> instance_;
00070 
00071     // Private Member Functions
00072 
00073         //- Disallow default bitwise copy construct
00074         IPstreamImpl(const IPstreamImpl&);
00075 
00076         //- Disallow default bitwise assignment
00077         void operator=(const IPstreamImpl&);
00078 
00079 public:
00080 
00081     // Declare name of the class and its debug switch
00082     TypeName("IPstreamImpl");
00083 
00084     // Declare run-time constructor selection table
00085 
00086         declareRunTimeSelectionTable
00087         (
00088             autoPtr,
00089             IPstreamImpl,
00090             dictionary,
00091             (),
00092             ()
00093         );
00094 
00095     // Constructors
00096 
00097         //- Construct null
00098         IPstreamImpl(){}
00099 
00100     // Destructor
00101 
00102         virtual ~IPstreamImpl() {}
00103 
00104     // Selectors
00105 
00106         //- Return a reference to the selected IPstreamImpl implementation
00107         static autoPtr<IPstreamImpl> New();
00108 
00109     // Member Functions
00110 
00111         //- Initialization
00112         virtual void init
00113         (
00114             const PstreamImpl::commsTypes commsType,
00115             const label bufSize,
00116             int& fromProcNo,
00117             label& messageSize,
00118             List<char>& buf
00119         ) = 0;
00120 
00121         //- Read into given buffer from given processor and return the
00122         //  message size
00123         virtual label read
00124         (
00125             const PstreamImpl::commsTypes commsType,
00126             const int fromProcNo,
00127             char* buf,
00128             const std::streamsize bufSize
00129         ) = 0;
00130 
00131         //- Non-blocking receives: wait until all have finished.
00132         virtual void waitRequests() = 0;
00133 
00134         //- Non-blocking receives: has request i finished?
00135         virtual bool finishedRequest(const label i) = 0;
00136 
00137 };
00138 
00139 
00140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00141 
00142 } // End namespace Foam
00143 
00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00145 
00146 #endif
00147 
00148 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines