Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SingleFileBuffer.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file protocols/jd2/MpiFileBuffer.hh
10 /// @brief header file for MPISilentFileJobOutputter class, part of August 2008 job distributor as planned at RosettaCon08
11 /// @detail this outputter will send silentstructs via MPI to dedicated node that will collect all structures
12 /// @author Oliver Lange olange@u.washington.edu
13 
14 
15 #ifndef INCLUDED_protocols_jd2_SingleFileBuffer_hh
16 #define INCLUDED_protocols_jd2_SingleFileBuffer_hh
17 
18 #ifdef USEMPI
19 #include <mpi.h>
20 #endif
21 
22 //unit headers
24 
25 //project headers
26 #include <core/types.hh>
27 
28 //utility headers
29 #include <utility/exit.hh>
30 // AUTO-REMOVED #include <utility/vector1.hh>
31 #include <utility/io/ozstream.hh>
32 #include <utility/pointer/ReferenceCount.hh>
33 
34 //C++ headers
35 #include <string>
36 #include <map>
37 
38 #include <utility/vector1_bool.hh>
39 
40 
41 namespace protocols {
42 namespace jd2 {
43 
44 ///@details this is a implementation of Buffer for silent-file-based output.
45 
47 protected:
49  typedef std::map< int, LineBuffer> BufferMap;
50 public:
51  SingleFileBuffer( std::string const & filename, core::Size channel, core::Size& status ) : filename_( filename ), mpi_channel_( channel ) { status = 0; };
52  virtual ~SingleFileBuffer();
53  void flush( core::Size slave );
54  void store_line( core::Size slave, core::Size channel, std::string const & line );
55  core::Size length( core::Size slave );
56  void close( core::Size slave );
57  bool has_open_slaves() const;
58  core::Size nr_open_slaves() const;
59  //a sequential block of lines hat come from a single slave node (i.e., a full-silent struct )
60  // called when flush() or close() is called on the stream on the slave node
61  virtual void write_lines( LineBuffer const & );
62  virtual void block( core::Size slave );
63  std::string const & filename() { return filename_; };
64 private:
68 };
69 
71 public:
73  virtual ~WriteFileSFB();
74  WriteFileSFB( std::string const & filename, core::Size channel, bool append, core::Size& status );
75  virtual void write_lines( LineBuffer const & );
76  virtual void block( core::Size slave );
77 private:
78  /// @brief PyRosetta workaround, make copy constructor private so it will not try to create copy methods
79  WriteFileSFB( WriteFileSFB const & src );
80 
81  std::ofstream out_;
82 };
83 
84 }
85 }
86 
87 #endif