Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JobOutputter.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 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/jd2/JobOutputter.hh
11 /// @brief header file for JobOutputter class, part of August 2008 job distributor as planned at RosettaCon08
12 /// @author Steven Lewis smlewi@gmail.com
13 
14 
15 #ifndef INCLUDED_protocols_jd2_JobOutputter_hh
16 #define INCLUDED_protocols_jd2_JobOutputter_hh
17 
18 //unit headers
20 #include <protocols/jd2/Job.fwd.hh>
21 #ifdef WIN32
22 #include <protocols/jd2/Job.hh> // WIN32 INCLUDE
23 #endif
24 
25 //project headers
26 #include <core/pose/Pose.fwd.hh>
27 
29 
31 
32 //utility headers
33 #include <utility/pointer/ReferenceCount.hh>
34 
35 //C++ headers
36 #include <string>
37 
38 #include <utility/vector1.hh>
39 
40 
41 namespace protocols {
42 namespace jd2 {
43 
44 ///@details the JobOutputter class is responsible for dealing with output, as well as determining what jobs have already been output and what sort of name is associated with a job. Derived classes will be responsible for output such as PDBS, PDBS.tar.gz and silent files.
46 {
47 public:
48 
49  //constructor -- reads cmd-line to initialize evaluators
50  JobOutputter();
51 
52  virtual ~JobOutputter();
53 
54  ///@brief this function is meant to be redefined in child classes to allow for flushing of memory buffers.
55 /// Here's the long version: The SilentFileJobOutputter wanted to buffer output, but needed to guaruntee that
56 /// the output would be flushed at end of runtime. The original implementation was to A) bend over backward to ensure
57 /// that the destructor was run (JobOutputter lives inside static JobDistributor, which was previously not destructed
58 /// because it's static) and B) flush the buffers in the destructor. This caused a problem because the buffer-flushing
59 /// tried to use the Tracers, which had already been destructed...boom crash.
60 ///
61 /// New solution: re-forbid use of destructors within the static JobDistributor system, and create a flush function to force this stuff out. So here it is:
62  virtual void flush();
63 
64  //////////////////////////////creating output functions/////////////////////////////////////////
65 
66  ///@brief this function takes a string and writes it to disk (separately from Tracer output).
67  ///use some sort of extention option system - default .dat? .data?
68  virtual
69  void file( JobCOP job, std::string const & data ) = 0;
70 
71  ///@brief this function outputs the final result of a job.
72  virtual
73  void final_pose( JobCOP job, core::pose::Pose const & pose ) = 0;
74 
75  ///@brief this function is intended for saving mid-protocol poses; for example the final centroid structure in a combined centroid/fullatom protocol.
76  virtual
77  void other_pose( JobCOP job, core::pose::Pose const & pose, std::string const & tag, int copy_count = -1, bool score_only = false ) = 0;
78 
79  ///@brief optionally pass a starting (reference) pose to a JobOutputter for later comparison purposes and/or as interface for initializing evaluators
80  virtual
81  void starting_pose( core::pose::Pose const & );
82 
83  /////////////////////////////////state of output functions/////////////////////////////////
84 
85  ///@brief this function is not used for output, but it belongs here since it needs to check the same output locations as the class normally writes to. This class checks wherever output goes to see if the job's expected output already exists (on disk or whatever). This is the most basic form of checkpointing.
86  virtual
87  bool job_has_completed( JobCOP job ) = 0;
88 
89  ///@brief this is the master function for determining the unique output identifier for a job - should this be defined in the base class?
90  virtual
91  std::string output_name( JobCOP job ) = 0;
92 
93  virtual
95  return "unknown_file";
96  }
97 
98  ///////////////////////////////// evaluator interface ////////////////////////////////////////////
99 public:
101 
103 
104  void clear_evaluators();
105 
107 
109 
110 private:
111 
113  //////////////////////////////// end evaluator interface /////////////////////////////////////////
114 
115 protected:
116  ///@brief this function provides the extended name, not just the output name. e.g output_name returns 1UBQ_0001, this returns 1UBQ_0001.pdb
117  //not necessary in the interface class - not all derived classes CAN implement this
118  //virtual
119  //std::string extended_name( JobCOP job ) = 0;
120 
121  ///@brief this function generates the affixed, numbered name for the job as prefix + input + suffix + number (affixes from options system). This function is deliberately not virtual, this should be a common mechanism; your JobOutputter can not call it if it would like.
123 
124 private:
125  ///@brief operator= defined for the sake of the remove-headers-in-headers initiative. As of this writing, there is no reason to actually call this function, so it is declared but UNIMPLEMENTED to force compiler errors if you try to do this (instead of allowing the compiler to autogenerate the code). If you have a valid need for this function, feel free to implement it properly and make it a public function.
126  JobOutputter & operator= (JobOutputter const & rhs);
127 
128  ///@brief copy ctor defined for the sake of the remove-headers-in-headers initiative. As of this writing, there is no reason to actually call this function, so it is declared but UNIMPLEMENTED to force compiler errors if you try to do this (instead of allowing the compiler to autogenerate the code). If you have a valid need for this function, feel free to implement it properly and make it a public function.
129  JobOutputter(JobOutputter const & cpy);
130 
131 }; // JobOutputter
132 
133 } // namespace jd2
134 } // namespace protocols
135 
136 #endif //INCLUDED_protocols_jd2_JobOutputter_HH