Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PoseEvaluator.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 relax_initialization_protocols
11 /// @brief initialization protocols for relax
12 /// @detailed
13 /// Contains currently: Classic Abinitio
14 ///
15 ///
16 /// @author Oliver Lange
17 
18 
19 
20 #ifndef INCLUDED_protocols_evaluation_PoseEvaluator_hh
21 #define INCLUDED_protocols_evaluation_PoseEvaluator_hh
22 
23 
24 // Unit Headers
26 
27 // Package Headers
28 
29 // Project Headers
31 #include <core/pose/Pose.fwd.hh>
32 
33 // ObjexxFCL Headers
34 
35 // Utility headers
36 #include <utility/pointer/ReferenceCount.hh>
37 // AUTO-REMOVED #include <utility/vector1.hh>
38 //// C++ headers
39 
40 // due to template function
42 
43 #include <utility/vector1.hh>
44 
45 
46 
47 namespace protocols {
48 namespace evaluation {
49 
51 public:
53  virtual ~PoseEvaluator() {};
54  // we may put a cache for user values into the pose, then it will just return a pose
55  // or return just the Map from strings to values...
56 
57  ///@brief evaluate pose and store values in Silent_Struct
58  virtual void apply( core::pose::Pose&, std::string tag, core::io::silent::SilentStruct &pss) const = 0;
59 
60  ///@brief direct application to SilentStruct...
61  /// default implementation makes pose and calls "apply", you can overload if you don't need the pose-step
62  virtual void apply( core::io::silent::SilentStruct &pss) const;
63  virtual bool applicable( core::pose::Pose const& ) const { return true; }
64 
65  virtual core::Size size() const = 0;
66  virtual std::string name( core::Size ) const = 0;
67 
68 };
69 
70 template <class T >
71 class SingleValuePoseEvaluator : public PoseEvaluator {
72 public:
74 
75  ///@brief evaluate pose and store values in Silent_Struct
76  /// why is this specific to a specific type of SilentStruct? that seems needlessly pointless and overly constraining.
77  virtual void apply( core::pose::Pose&, std::string tag, core::io::silent::SilentStruct &pss) const;
78  // void apply( core::pose::Pose&, std::string tag, core::io::silent::SilentStruct &pss) const;
79 
81 
82  ///@brief evaluate pose
83  virtual T apply( core::pose::Pose& ) const = 0;
84  virtual bool applicable( core::pose::Pose const& ) const { return true; }
85 
86  // void apply( core::pose::Pose&, std::string tag, core::io::silent::SilentStruct &pss) const;
87 
88  virtual core::Size size() const { return 1; }
89  virtual std::string name( core::Size ) const {
90  return name_;
91  }
92 
93 private:
95 
96 };
97 
98 //now also named PoseEvaluators ( see typedef below )
99 //typedef MetaPoseEvaluator PoseEvaluators; //moved to .fwd.hh, SML 09/09/2009
100 
102 public:
105 
107 
108  virtual void
110 
111  void
113  evaluators_.push_back( pe );
114  }
115 
116  /// @brief clear the list of evaluators
117  void
118  clear() {
119  evaluators_.clear();
120  }
121 
122  //removes last element
123  void
125  evaluators_.pop_back();
126  }
127 
129  add_evaluation( pe );
130  return *this;
131  }
132 
133  Size size() const {
134  Size s( 0 );
135  for ( EvaluatorList::const_iterator it = evaluators_.begin(); it != evaluators_.end(); ++it ) {
136  s += (*it)->size();
137  }
138  return s;
139  }
140 
141  virtual std::string name( core::Size ind ) const;
142 
143  EvaluatorList const& evaluators() { return evaluators_; }
144 
145 private:
147 };
148 
149 
150 //@brief evaluate pose and store values in Silent_Struct
151 template< class T >
153  if ( applicable( pose ) ) pss.add_energy ( name_, apply( pose ) );
154 }
155 
156 }
157 }
158 #endif