Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RotamerRecoveryFactory.cc
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/rotamer_recovery/RotamerRecoveryFactory.cc
11 /// @brief Factory for creating RotamerRecoverys objects
12 /// @author Matthew O'Meara (mattjomeara@gmail.com)
13 
14 // Unit Headers
21 
22 // Package Headers
23 #include <basic/Tracer.hh>
24 // AUTO-REMOVED #include <protocols/moves/Mover.hh>
25 // AUTO-REMOVED #include <utility/tag/Tag.hh>
26 // AUTO-REMOVED #include <utility/sql_database/DatabaseSessionManager.hh>
27 
28 // Project Headers
29 // AUTO-REMOVED #include <core/scoring/ScoreFunction.hh>
30 // AUTO-REMOVED #include <protocols/jobdist/Jobs.hh>
31 #include <utility/vector0.hh>
32 
33 // Boost Headers
34 #include <boost/foreach.hpp>
35 #define foreach BOOST_FOREACH
36 
37 // C++ Headers
38 #include <string>
39 #include <sstream>
40 
41 //Auto Headers
42 #include <utility/exit.hh>
43 #include <utility/vector1.hh>
44 
45 namespace protocols {
46 namespace rotamer_recovery {
47 
48 using std::endl;
49 using std::string;
50 using std::stringstream;
51 using core::pose::Pose;
53 
54 static basic::Tracer tr("protocols.rotamer_recovery.RotamerRecoveryFactory");
55 
56 RotamerRecoveryFactory * RotamerRecoveryFactory::instance_( 0 );
57 
58 /// @details Private constructor insures correctness of singleton.
60 
63 ) {}
64 
66 
67 
70 {
71  if ( instance_ == 0 ) {
73  }
74  return instance_;
75 }
76 
77 
78 void
80  RRProtocolCreatorCOP creator
81 ) {
82  protocol_types_[ creator->type_name() ] = creator;
83 }
84 
85 void
87  RRComparerCreatorCOP creator
88 ) {
89  comparer_types_[ creator->type_name() ] = creator;
90 }
91 
92 void
94  RRReporterCreatorCOP creator
95 ) {
96  reporter_types_[ creator->type_name() ] = creator;
97 }
98 
99 
102  string const & type_name
103 ) {
104  tr.Trace << "get rotamer recovery protocol of type '" << type_name << "'" << endl;
105  RRProtocolCreatorMap::const_iterator iter = protocol_types_.find( type_name );
106  if (iter != protocol_types_.end()) {
107  return iter->second->create_protocol();
108  } else {
109 
110  stringstream error_msg;
111  error_msg
112  << "Attempting to create unrecognized rotamer recovery protocol "
113  << "'" << type_name << "'." << endl
114  << "check spelling or "
115  << "register a new RRProtocol with the RotamerRecoveryFactory" << endl
116  << "known RRProtocol types are:" << endl;
117 
118  foreach(const RRProtocolCreatorMap::value_type& type, protocol_types_){
119  error_msg << "\t" << type.first << endl;
120  }
121  utility_exit_with_message(error_msg.str());
122  }
123  return 0;
124 }
125 
128  string const & type_name
129 ) {
130  tr.Trace << "get rotamer recovery comparer of type '" << type_name << "'" << endl;
131  RRComparerCreatorMap::const_iterator iter = comparer_types_.find( type_name );
132  if (iter != comparer_types_.end()) {
133  return iter->second->create_comparer();
134  } else {
135 
136  stringstream error_msg;
137  error_msg
138  << "Attempting to create unrecognized rotamer recovery comparer "
139  << "'" << type_name << "'." << endl
140  << "check spelling or "
141  << "register a new RRComparer with the RotamerRecoveryFactory" << endl
142  << "known RRComparer types are:" << endl;
143 
144  foreach(const RRComparerCreatorMap::value_type& type, comparer_types_){
145  error_msg << "\t" << type.first << endl;
146  }
147  utility_exit_with_message(error_msg.str());
148  }
149  return 0;
150 }
151 
154  string const & type_name
155 ) {
156  tr.Trace << "get rotamer recovery reporter of type '" << type_name << "'" << endl;
157  RRReporterCreatorMap::const_iterator iter = reporter_types_.find( type_name );
158  if (iter != reporter_types_.end()) {
159  return iter->second->create_reporter();
160  } else {
161 
162  stringstream error_msg;
163  error_msg
164  << "Attempting to create unrecognized rotamer recovery reporter "
165  << "'" << type_name << "'." << endl
166  << "check spelling or "
167  << "register a new RRReporter with the RotamerRecoveryFactory" << endl
168  << "known RRReporter types are:" << endl;
169 
170  foreach(const RRReporterCreatorMap::value_type& type, reporter_types_){
171  error_msg << "\t" << type.first << endl;
172  }
173  utility_exit_with_message(error_msg.str());
174  }
175  return 0;
176 }
177 
180  string const & protocol_name,
181  string const & comparer_name,
182  string const & reporter_name
183 ) {
184  return new RotamerRecovery(
185  get_rotamer_recovery_protocol(protocol_name),
186  get_rotamer_recovery_comparer(comparer_name),
187  get_rotamer_recovery_reporter(reporter_name));
188 }
189 
190 } // namespace
191 } // namespace