FreeFOAM The Cross-Platform CFD Toolkit
OPstreamImpl.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::OPstreamImpl
32 
33 Description
34  Abstract base class for OPstream operations that depend on the parallel
35  library used. Foam::OPstreamImpl::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>OPstreamImpl.
40 
41 SourceFiles
42  OPstreamImpl.C
43 
44 
45 \*----------------------------------------------------------------------------*/
46 
47 #ifndef OPstreamImpl_H
48 #define OPstreamImpl_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 OPstreamImpl Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 {
66  // Private data
67 
68  //- The singleton instance
69  static autoPtr<OPstreamImpl> instance_;
70 
71  // Private Member Functions
72 
73  //- Disallow default bitwise copy construct
74  OPstreamImpl(const OPstreamImpl&);
75 
76  //- Disallow default bitwise assignment
77  void operator=(const OPstreamImpl&);
78 
79 public:
80 
81  // Declare name of the class and its debug switch
82  TypeName("OPstreamImpl");
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  // Selectors
101 
102  //- Return a reference to the selected OPstreamImpl implementation
103  static autoPtr<OPstreamImpl> New();
104 
105  // Member Functions
106 
107  //- Write given buffer to given processor
108  virtual bool write
109  (
110  const PstreamImpl::commsTypes commsType,
111  const int toProcNo,
112  const char* buf,
113  const std::streamsize bufSize
114  ) = 0;
115 
116  //- Non-blocking writes: wait until all have finished.
117  virtual void waitRequests() = 0;
118 
119  //- Non-blocking writes: has request i finished?
120  virtual bool finishedRequest(const label i) = 0;
121 
122  //- Flush the buffer (used in OPstream::~OPstream())
123  virtual void flush
124  (
125  const PstreamImpl::commsTypes commsType,
126  const int toProcNo,
127  const char* buf,
128  const int bufPosition
129  ) = 0;
130 
131 
132 };
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace Foam
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #endif
142 
143 // ************************ vim: set sw=4 sts=4 et: ************************ //