Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VallLibrary.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 core/fragment/picking_old/vall/VallLibrary.hh
11 /// @brief Vall fragment library
12 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
13 
14 #ifndef INCLUDED_core_fragment_picking_old_vall_VallLibrary_hh
15 #define INCLUDED_core_fragment_picking_old_vall_VallLibrary_hh
16 
17 // unit headers
19 
20 // package headers
23 
24 #include <utility/vector1.hh>
25 
26 
27 // utility headers
28 
29 
30 namespace core {
31 namespace fragment {
32 namespace picking_old {
33 namespace vall {
34 
35 
36 /// @brief Vall fragment library
38 
39 
40 private: // typedefs
41 
42 
44 
45 
46 public: // typedefs
47 
48 
49  typedef Super::Size Size;
50 
51 
52 public: // concept typedefs
53 
54 
55  /// @brief typedef for Library concept
57 
58 
59  /// @brief typedef for Library concept
61 
62 
63 public: // concept translation typedefs
64 
65 
68 
69 
70 public: // operators
71 
72 
73  /// @brief access a specific VallSection within this section, 1-based indexing
74  inline
75  VallSection const & operator[]( Size const idx ) const {
76  return sections()[ idx ];
77  }
78 
79 
80 public: // section management
81 
82 
83  /// brief add a section to the end of this library
84  inline
85  void add_section( VallSection const & section ) {
86  sections().push_back( section );
87  sections().back().index( sections().size() );
88  }
89 
90 
91  /// @brief access the last section in thie library
92  inline
93  VallSection const & last_section() const {
94  return sections().back();
95  }
96 
97 
98  /// @brief access the last section in thie library
99  inline
101  return sections().back();
102  }
103 
104 
105  /// @brief total number of residues in the library
106  inline
107  Size n_residues() const {
108  Size n = 0;
109  for ( VallSectionConstIterator i = begin(), ie = end(); i != ie; ++i ) {
110  n += i->size();
111  }
112  return n;
113  }
114 
115 
116  /// @brief re-index VallSections within this library so they number 1 .. n
117  inline
119  Size count = 0;
120  for ( VallSectionIterator i = begin(), ie = end(); i != ie; ++i ) {
121  i->index( ++count );
122  }
123  }
124 
125 
126 public: // memory
127 
128 
129  /// @brief ensure storage currently allocated for VallSections is at least the
130  /// given size
131  inline
132  void reserve( Size const n ) {
133  sections().reserve( n );
134  }
135 
136 
137  /// @brief tighten memory usage
138  /// @param sections_only if true, only tightens memory per-section and skips
139  /// the operation for the whole library
140  /// @details Shrinks the capacity of the library by calling
141  /// <tt>VallSection::tighten_memory()</tt> for each section. If 'sections_only' is
142  /// false, will additionally perform a swap of the library, effectively
143  /// requiring a similar amount of memory as the current library object.
144  /// @warning The Vall libraries can be very large, so set 'sections_only'
145  /// false only if you won't be running on a constrained memory platform.
146  inline
147  void tighten_memory( bool const sections_only = true ) {
148  for ( VallSectionIterator i = begin(), ie = end(); i != ie; ++i ) {
149  i->tighten_memory();
150  }
151 
152  // the following could require a lot of memory
153  if ( !sections_only ) {
154  VallSections( sections() ).swap( sections() );
155  }
156  }
157 
158 
159 private: // concept translation
160 
161 
162  /// @brief return sections container
163  inline
164  VallSections const & sections() const {
165  return books();
166  }
167 
168 
169  /// @brief return sections container
170  inline
172  return books();
173  }
174 
175 
176 };
177 
178 
179 } // vall
180 } // picking_old
181 } // fragment
182 } // core
183 
184 
185 #endif /* INCLUDED_core_fragment_picking_old_vall_VallLibrary_HH */