Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PolicyFactory.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/nonlocal/PolicyFactory.cc
11 /// @author Christopher Miles (cmiles@uw.edu)
12 
13 // Unit header
15 
16 // C/C++ headers
17 #include <string>
18 
19 // External headers
20 #include <boost/algorithm/string/case_conv.hpp>
21 
22 // Utility headers
23 #include <utility/exit.hh>
24 
25 // Project headers
26 #include <core/types.hh>
27 #include <core/fragment/FragSet.hh>
28 #include <core/fragment/util.hh>
29 
30 // Package headers
34 
35 #include <utility/vector1.hh>
36 
37 
38 namespace protocols {
39 namespace nonlocal {
40 
43  core::Size num_fragments) {
44  assert(fragments);
45  assert(num_fragments > 0);
46 
47  std::string type(policy_name);
48  boost::to_lower(type);
49 
50  // Operate on a copy of the input to prevent unexpected (and unwanted)
51  // modification to the user's fragment data.
52  core::fragment::FragSetOP reduced_fragments = fragments->clone();
53 
54  // Only consider the top <num_fragments> fragments within each Frame.
55  core::fragment::retain_top(num_fragments, reduced_fragments);
56 
57  if (type == "uniform") {
58  return new UniformPolicy(reduced_fragments);
59  } else if (type == "smooth") {
60  return new SmoothPolicy(reduced_fragments);
61  } else {
62  utility_exit_with_message("Invalid policy_name: " + policy_name);
63  }
64  return NULL;
65 }
66 
67 } // namespace nonlocal
68 } // namespace protocols