Escript  Revision_4320
FileWriter.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15 
16 #ifndef __WEIPA_FILEWRITER_H__
17 #define __WEIPA_FILEWRITER_H__
18 
19 #include <weipa/weipa.h>
20 
21 #include <fstream>
22 
23 namespace weipa {
24 
26 {
27 public:
28  FileWriter();
29 
30 #if HAVE_MPI
31  FileWriter(MPI_Comm comm);
32 #endif
33 
34  bool openFile(std::string filename);
35  bool writeOrdered(std::ostringstream& oss);
36  bool writeShared(std::ostringstream& oss);
37  void close();
38 
39 private:
41 #if HAVE_MPI
43  MPI_File fileHandle;
44 #else
45  void* mpiComm;
46 #endif
47  std::ofstream ofs;
48 };
49 
50 } // namespace weipa
51 
52 #endif // __WEIPA_FILEWRITER_H__
53