ENH: Update FreeFOAM contributions to GPL v3
[freefoam.git] / src / OpenFOAM / db / IOstreams / Pstreams / IPstreamImpl.H
bloba613783e265e6ff0641243d5e3439100fa797745
1 /*----------------------------------------------------------------------------*\
2                 ______                _     ____          __  __
3                |  ____|             _| |_  / __ \   /\   |  \/  |
4                | |__ _ __ ___  ___ /     \| |  | | /  \  | \  / |
5                |  __| '__/ _ \/ _ ( (| |) ) |  | |/ /\ \ | |\/| |
6                | |  | | |  __/  __/\_   _/| |__| / ____ \| |  | |
7                |_|  |_|  \___|\___|  |_|   \____/_/    \_\_|  |_|
9                     FreeFOAM: The Cross-Platform CFD Toolkit
11   Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
12                           Gerber van der Graaf <gerber_graaf@users.sf.net>
13 --------------------------------------------------------------------------------
14 License
15     This file is part of FreeFOAM.
17     FreeFOAM is free software: you can redistribute it and/or modify it
18     under the terms of the GNU General Public License as published by the
19     Free Software Foundation, either version 3 of the License, or (at your
20     option) any later version.
22     FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
23     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25     for more details.
27     You should have received a copy of the GNU General Public License
28     along with FreeFOAM.  If not, see <http://www.gnu.org/licenses/>.
30 Class
31     Foam::IPstreamImpl
33 Description
34     Abstract base class for IPstream operations that depend on the parallel
35     library used. Foam::IPstreamImpl::New will lookup the entry
36     "PstreamImplementation" in the global controlDict file (i.e. the one
37     found by Foam::dotFoam) and tries to first load a library named
38     lib\<PstreamImplementation\>Pstream.so, and then instantiate the class
39     \<PstreamImplementation\>IPstreamImpl.
41 SourceFiles
42     IPstreamImpl.C
45 \*----------------------------------------------------------------------------*/
47 #ifndef IPstreamImpl_H
48 #define IPstreamImpl_H
50 #include <OpenFOAM/PstreamImpl.H>
51 #include <OpenFOAM/autoPtr.H>
52 #include <OpenFOAM/typeInfo.H>
53 #include <OpenFOAM/runTimeSelectionTables.H>
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 namespace Foam
60 /*---------------------------------------------------------------------------*\
61                            Class IPstreamImpl Declaration
62 \*---------------------------------------------------------------------------*/
64 class IPstreamImpl
66     // Private data
68         //- The singleton instance
69         static autoPtr<IPstreamImpl> instance_;
71     // Private Member Functions
73         //- Disallow default bitwise copy construct
74         IPstreamImpl(const IPstreamImpl&);
76         //- Disallow default bitwise assignment
77         void operator=(const IPstreamImpl&);
79 public:
81     // Declare name of the class and its debug switch
82     TypeName("IPstreamImpl");
84     // Declare run-time constructor selection table
86         declareRunTimeSelectionTable
87         (
88             autoPtr,
89             IPstreamImpl,
90             dictionary,
91             (),
92             ()
93         );
95     // Constructors
97         //- Construct null
98         IPstreamImpl(){}
100     // Destructor
102         virtual ~IPstreamImpl() {}
104     // Selectors
106         //- Return a reference to the selected IPstreamImpl implementation
107         static autoPtr<IPstreamImpl> New();
109     // Member Functions
111         //- Initialization
112         virtual void init
113         (
114             const PstreamImpl::commsTypes commsType,
115             const label bufSize,
116             int& fromProcNo,
117             label& messageSize,
118             List<char>& buf
119         ) = 0;
121         //- Read into given buffer from given processor and return the
122         //  message size
123         virtual label read
124         (
125             const PstreamImpl::commsTypes commsType,
126             const int fromProcNo,
127             char* buf,
128             const std::streamsize bufSize
129         ) = 0;
131         //- Non-blocking receives: wait until all have finished.
132         virtual void waitRequests() = 0;
134         //- Non-blocking receives: has request i finished?
135         virtual bool finishedRequest(const label i) = 0;
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 } // End namespace Foam
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 #endif
148 // ************************ vim: set sw=4 sts=4 et: ************************ //