FreeFOAM The Cross-Platform CFD Toolkit
IPstreamImpl.H
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*\
2  ______ _ ____ __ __
3  | ____| _| |_ / __ \ /\ | \/ |
4  | |__ _ __ ___ ___ / \| | | | / \ | \ / |
5  | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
6  | | | | | __/ __/\_ _/| |__| / ____ \| | | |
7  |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
8 
9  FreeFOAM: The Cross-Platform CFD Toolkit
10 
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.
16 
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.
21 
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.
26 
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/>.
29 
30 Class
31  Foam::IPstreamImpl
32 
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.
40 
41 SourceFiles
42  IPstreamImpl.C
43 
44 
45 \*----------------------------------------------------------------------------*/
46 
47 #ifndef IPstreamImpl_H
48 #define IPstreamImpl_H
49 
50 #include <OpenFOAM/PstreamImpl.H>
51 #include <OpenFOAM/autoPtr.H>
52 #include <OpenFOAM/typeInfo.H>
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class IPstreamImpl Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 {
66  // Private data
67 
68  //- The singleton instance
69  static autoPtr<IPstreamImpl> instance_;
70 
71  // Private Member Functions
72 
73  //- Disallow default bitwise copy construct
74  IPstreamImpl(const IPstreamImpl&);
75 
76  //- Disallow default bitwise assignment
77  void operator=(const IPstreamImpl&);
78 
79 public:
80 
81  // Declare name of the class and its debug switch
82  TypeName("IPstreamImpl");
83 
84  // Declare run-time constructor selection table
85 
87  (
88  autoPtr,
90  dictionary,
91  (),
92  ()
93  );
94 
95  // Constructors
96 
97  //- Construct null
99 
100  // Destructor
101 
102  virtual ~IPstreamImpl() {}
103 
104  // Selectors
105 
106  //- Return a reference to the selected IPstreamImpl implementation
107  static autoPtr<IPstreamImpl> New();
108 
109  // Member Functions
110 
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;
120 
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;
130 
131  //- Non-blocking receives: wait until all have finished.
132  virtual void waitRequests() = 0;
133 
134  //- Non-blocking receives: has request i finished?
135  virtual bool finishedRequest(const label i) = 0;
136 
137 };
138 
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 } // End namespace Foam
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************ vim: set sw=4 sts=4 et: ************************ //