Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PoseMetricCalculatorBase.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
11 /// @brief
12 /// @author John Karanicolas
13 
14 
15 #ifndef INCLUDED_core_pose_metrics_PoseMetricCalculatorBase_hh
16 #define INCLUDED_core_pose_metrics_PoseMetricCalculatorBase_hh
17 
19 
20 #include <core/pose/Pose.fwd.hh>
21 #include <basic/MetricValue.fwd.hh>
22 
23 #include <utility/pointer/ReferenceCount.hh>
24 #include <utility/pointer/owning_ptr.hh>
25 
26 // C++ Headers
27 #include <iostream>
28 
29 #include <utility/vector1.hh>
30 
31 
32 namespace core {
33 namespace pose {
34 namespace metrics {
35 
36 // Note: PoseMetricCalculator is an abstract base class for
37 // "StuctureDependentCalculator" and "EnergyDependentCalculator".
38 // Note: "SequenceDependentCalculator" may come later...
39 
40 // Other assorted calculator types derive from
41 // StuctureDependentCalculator and SequenceDependentCalculator
42 // These derived classes should hold cached data, and define the following three functions:
43 // "recompute" (update all cached data)
44 // "lookup" (return the value of a piece of cached data inside a MetricValue)
45 // "print" (return the value of a piece of cached data as a string)
46 // Note: Derived classes should NOT redefine "get"
47 
49 public:
50 
52  //these functions are not defined and thus should not be in the header
53  //PoseMetricCalculator( PoseMetricCalculator const & src );
54  //PoseMetricCalculator const & operator=( PoseMetricCalculator const & src );
55  virtual PoseMetricCalculatorOP clone() const = 0;
56 
57  virtual void notify_structure_change() { return; };
58  // virtual void notify_sequence_change() { return; };
59  virtual void notify_energy_change() { return; };
60 
61  virtual void get( std::string const & key, basic::MetricValueBase & val, Pose const & this_pose ) = 0;
62 
63  virtual std::string get( std::string const & key, Pose const & this_pose ) = 0;
64 
65 protected:
66 
67  virtual void lookup( std::string const & key, basic::MetricValueBase * valptr ) const = 0;
68 
69  virtual std::string print( std::string const & key ) const = 0;
70 
71  virtual void recompute( Pose const & this_pose ) = 0;
72 
73 };
74 
75 
77 public:
80  void get( std::string const & key, basic::MetricValueBase & val, Pose const & this_pose ) {
81  if ( structure_is_outdated_ ) recompute( this_pose );
82  structure_is_outdated_ = false;
83  lookup( key, &val );
84  };
85  std::string get( std::string const & key, Pose const & this_pose ) {
86  if ( structure_is_outdated_ ) recompute( this_pose );
87  structure_is_outdated_ = false;
88  return print( key );
89  };
90 protected:
91  virtual void lookup( std::string const & key, basic::MetricValueBase * valptr ) const = 0;
92  virtual std::string print( std::string const & key ) const = 0;
93  virtual void recompute( Pose const & this_pose ) = 0;
94 private:
96 };
97 
98 /*
99 class SequenceDependentCalculator : public PoseMetricCalculator {
100 public:
101  SequenceDependentCalculator() : PoseMetricCalculator(), sequence_is_outdated_(true) {};
102  void notify_sequence_change() { sequence_is_outdated_ = true; };
103  void get( std::string const & key, basic::MetricValueBase & val, Pose const & this_pose ) {
104  if ( sequence_is_outdated_ ) recompute( this_pose );
105  sequence_is_outdated_ = false;
106  lookup( key, &val );
107  };
108  std::string get( std::string const & key, Pose const & this_pose ) {
109  if ( sequence_is_outdated_ ) recompute( this_pose );
110  sequence_is_outdated_ = false;
111  return print( key );
112  };
113 protected:
114  virtual void lookup( std::string const & key, basic::MetricValueBase * valptr ) const = 0;
115  virtual std::string print( std::string const & key ) const = 0;
116  virtual void recompute( Pose const & this_pose ) = 0;
117 private:
118  bool sequence_is_outdated_;
119 };
120 */
121 
123 public:
126  void get( std::string const & key, basic::MetricValueBase & val, Pose const & this_pose ) {
127  if ( energies_are_outdated_ ) recompute( this_pose );
128  energies_are_outdated_ = false;
129  lookup( key, &val );
130  };
131  std::string get( std::string const & key, Pose const & this_pose ) {
132  if ( energies_are_outdated_ ) recompute( this_pose );
133  energies_are_outdated_ = false;
134  return print( key );
135  };
136 protected:
137  virtual void lookup( std::string const & key, basic::MetricValueBase * valptr ) const = 0;
138  virtual std::string print( std::string const & key ) const = 0;
139  virtual void recompute( Pose const & this_pose ) = 0;
140 private:
142 };
143 
144 
145 
146 } // namespace metrics
147 } // namespace pose
148 } // namespace core
149 
150 
151 #endif