Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FeaturesReporterFactory.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/features/FeaturesReporterFactory.cc
11 /// @brief Factory for creating FeaturesReporters objects
12 /// @author Matthew O'Meara (mattjomeara@gmail.com)
13 
14 // Unit Headers
18 
19 // Package Headers
20 #include <basic/Tracer.hh>
21 // AUTO-REMOVED #include <protocols/moves/Mover.hh>
22 #include <utility/tag/Tag.hh>
23 
24 // Project Headers
26 #include <utility/vector0.hh>
27 
28 // Boost Headers
29 #include <boost/foreach.hpp>
30 #define foreach BOOST_FOREACH
31 
32 // C++ Headers
33 #include <sstream>
34 
35 //Auto Headers
36 #include <utility/vector1.hh>
37 
38 
39 
40 
41 
42 namespace protocols {
43 namespace features {
44 
45 using std::endl;
46 using std::string;
47 using std::stringstream;
48 using core::pose::Pose;
54 
55 static basic::Tracer tr("protocols.features.FeaturesReporterFactory");
56 
57 FeaturesReporterFactory * FeaturesReporterFactory::instance_( 0 );
58 
59 /// @details Private constructor insures correctness of singleton.
61 
64 ) {}
65 
67 
68 
71 {
72  if ( instance_ == 0 ) {
74  }
75  return instance_;
76 }
77 
78 
79 void
82 ) {
83  types_[ creator->type_name() ] = creator;
84 }
85 
86 
89  string const & type_name
90 ) {
91  tr.Trace << "generate features reporter of type " << type_name << std::endl;
92  FeaturesReporterCreatorMap::const_iterator iter = types_.find( type_name );
93  if (iter != types_.end()) {
94  return iter->second->create_features_reporter();
95  } else {
96  stringstream error_msg;
97  error_msg
98  << "Attempting to create unrecognized FeaturesReporter "
99  << "'" << type_name << "'." << endl
100  << "check spelling or "
101  << "register a new FeaturesReporter in the FeaturesReporterFactory" << endl
102  << "known FeaturesReporter types are:" << endl;
103 
104  foreach(const FeaturesReporterCreatorMap::value_type& type, types_){
105  error_msg << "\t" << type.first << endl;
106  }
107  utility_exit_with_message(error_msg.str());
108  }
109  return 0;
110 }
112 {
114  FeaturesReporterCreatorMap::const_iterator iter = types_.begin();
115  while ( iter != types_.end() ) {
116  collection.push_back(iter->first);
117  iter++;
118  }
119  return collection;
120 
121 }
124  TagPtr const tag,
125  DataMap & data,
126  Filters_map const & filters,
127  Movers_map const & movers,
128  Pose const & pose
129 ) {
130  assert(tag->getName() == "feature");
131 
132  string type_name;
133  if(!tag->hasOption("name")){
134  utility_exit_with_message("'feature' tags require a name field");
135  } else {
136  type_name = tag->getOption<string>("name");
137  }
138 
139  FeaturesReporterOP features_reporter(get_features_reporter(type_name));
140 
141  features_reporter->parse_my_tag(tag, data, filters, movers, pose);
142  return features_reporter;
143 }
144 
145 } // namespace
146 } // namespace