Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OrderedFragSetIterator_.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file core/fragments/ConstantLengthFragSet.hh
12 /// @brief yields a simple implementation of a fragset
13 /// @author Oliver Lange ( olange@u.washington.edu)
14 /// @date Wed Aug 22 12:08:31 2007
15 ///
16 
17 #ifndef INCLUDED_core_fragment_OrderedFragSetIterator__HH
18 #define INCLUDED_core_fragment_OrderedFragSetIterator__HH
19 
20 // Unit Headers
21 //#include <core/fragment/ConstantLengthFragSet.fwd.hh>
22 
23 // Package Headers
26 //#include <core/fragment/OrderedFragSet.hh>
27 
28 //#include <core/fragment/FragSet.hh>
29 //#include <core/fragment/Frame.hh>
30 //#include <core/fragment/Frame.fwd.hh>
31 // AUTO-REMOVED #include <core/fragment/FrameIterator.hh>
32 
33 // AUTO-REMOVED #include <core/fragment/OrderedFragSet.fwd.hh>
34 
35 // Project Headers
36 //#include <core/pose/Pose.hh>
37 //#include <core/kinematics/MoveMap.hh>
38 #include <core/types.hh>
39 
40 // ObjexxFCL Headers
41 
42 // Utility headers
43 #include <utility/vector1.fwd.hh>
44 #include <utility/pointer/ReferenceCount.hh>
45 
46 // std Headers
47 // AUTO-REMOVED #include <iterator>
48 
49 #include <core/fragment/Frame.hh>
50 #include <utility/vector1.hh>
51 
52 
53 /* Just a mad thought: with fragments becoming ever more "Residue" like one might want to use the
54  packer to choose a combination of good fragments instead of makeing independent choices.
55  I guess, it is only a question of keeping the combinatorics in control...
56  maybe it makes sense to pack with only "unconfident" regions of the backbone flexible ..
57 */
58 
59 namespace core {
60 namespace fragment {
61 
62 /* iterate over a map of vectors such that if feels like a flat data-structure */
64  friend class OrderedFragSet;
65  typedef std::map< Size, FrameList > FrameMap;
66  typedef FrameMap::const_iterator OuterIterator;
67  typedef FrameList::const_iterator InnerIterator;
68 protected:
70  if ( outer_ != outer_end_ ) {
71  inner_ = outer_->second.begin();
72  inner_end_ = outer_->second.end();
73  if ( !(inner_ != inner_end_) ) increment_outer();
74  else if ( (*this)->nr_frags() == 0 ) ++(*this); //move forward to first real frame
75  }
76  };
77 
78  virtual bool operator != ( FrameIteratorWorker_ const& fiw ) const {
79  OrderedFragSetIterator_ const& fsit ( dynamic_cast< OrderedFragSetIterator_ const& > ( fiw ) );
80  bool bOut ( outer_!=fsit.outer_ );
81  if ( !bOut && fsit.outer_ != fsit.outer_end_ && outer_ != outer_end_ ) {
82  return inner_ != fsit.inner_;
83  } else return bOut;
84  };
85 
87  if ( increment_inner() ) return *this; //increment inner-loop to the end
88  increment_outer(); //then increment outer-loop
89  return *this;
90  }
91 
92  bool increment_outer () {
93  while ( ++outer_ != outer_end_ ) {
94  inner_ = outer_->second.begin();
95  inner_end_ = outer_->second.end();
96  if ( inner_ != inner_end_ ) {
97  if ( (*inner_)->nr_frags() ) return true;
98  else if ( increment_inner() ) return true;
99  }
100  }
101  return false;
102  }
103 
104  bool increment_inner () {
105  while ( ++inner_ != inner_end_ ) {
106  if ( (*inner_)->nr_frags() ) return true;
107  }
108  return false;
109  }
110 
111 
113  OrderedFragSetIterator_ const& fsit ( dynamic_cast< OrderedFragSetIterator_ const& > ( fiw ) );
114  inner_ = fsit.inner_;
115  inner_end_ = fsit.inner_end_;
116  outer_ = fsit.outer_;
117  outer_end_ = fsit.outer_end_;
118  return *this;
119  }
120 
121  virtual FrameOP frame_ptr() {
122  return *inner_; //call get() of owning_ptr
123  }
124 
125  virtual FrameCOP frame_ptr() const {
126  return *inner_; //call get() of owning_ptr
127  }
128 
129 private:
134 };
135 
136 }
137 }
138 
139 #endif