Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RawFileData.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/io/raw_data/RawFileData.hh
12 ///
13 /// @brief FileData base class
14 /// @author James Thompson, Monica Berrondo
15 
16 #ifndef INCLUDED_core_io_raw_data_RawFileData_hh
17 #define INCLUDED_core_io_raw_data_RawFileData_hh
18 
19 // mini headers
20 #include <core/types.hh>
21 
24 
25 // AUTO-REMOVED #include <utility/file/file_sys_util.hh>
26 
27 // C++ Headers
28 // AUTO-REMOVED #include <string>
29 
30 #include <utility/vector1.hh>
31 
32 
33 namespace core {
34 namespace io {
35 namespace raw_data {
36  /// @brief Abstract base class for classes that writes different types of
37  /// silent-files that contain a mixture of Struct objects which are expected
38  /// to be uniquely identified by some sort of string-based tag.
39  class RawFileData {
40  public:
41  ///////////////////////////////////////////////////////////////////////////
42  // constructor
43 
45 
46  /// @brief Destructor.
47  virtual ~RawFileData() {
49  }
50 
51  /// @brief Returns the number of structures contained in this container.
52  int size() const { return structure_map_.size(); }
53 
54  /// @brief Returns the number of residues in the first structure in this object. Not
55  /// guaranteed to be fixed for all structures in this container.
56  int nres() const {
57  return begin_const()->nres();
58  }
59 
60  /// @brief Returns the sequence of the first structure in this object. Not
61  /// guaranteed to be fixed for all structures in this container.
63  return sequence_;
64  }
65 
66  /// @brief Remove all of the RawStruct objects from this object.
68  {
69  structure_map_.clear();
70  }
71 
72  /// @brief quickly read a list of tags from a silent-input file. Only checks lines beginning
73  /// with SCORE: strings.
75 
76  /// @brief write all RawStruct objects in the structure_map_ to the given filename.
77  void write_all( const std::string filename, std::map < std::string, core::Real > const & score_map );
78 
79  protected:
80  // mapping from tags to structure data pointers
83 
84  public:
85  class const_iterator;
86 
87  /// @brief Iterator class for RawFileData container.
88  class iterator {
89 
90  friend class const_iterator;
91 
92  public:
93  /// @brief empty constructor
94  iterator() {}
95 
96  /// @brief Constructor, given an iterator into the StructureMap.
97  iterator( StructureMap::iterator s_iter ) {
98  it_ = s_iter;
99  }
100 
102 
103  iterator& operator=( const iterator& src ) {
104  it_ = src.it_;
105  return (*this);
106  }
107 
108  bool operator==( const iterator& other ) {
109  return ( it_ == other.it_ );
110  }
111 
112  bool operator!=( const iterator& other ) {
113  return ( it_ != other.it_ );
114  }
115 
117  it_++;
118  return (*this);
119  }
120 
122  return it_->second();
123  }
124 
126  return it_->second;
127  }
128 
129  private:
130  StructureMap::iterator it_; // keep track of my place in a StructureMap
131  }; // class iterator
132 
133  /// @brief const_iterator class for RawFileData container.
135 
136  public:
137  /// @brief empty constructor
139 
140  /// @brief Constructor, given an iterator into the StructureMap.
141  const_iterator( StructureMap::const_iterator s_iter ) {
142  it_ = s_iter;
143  }
144 
146 
148  it_ = src.it_;
149  return (*this);
150  }
151 
152  bool operator==( const const_iterator& other ) {
153  return ( it_ == other.it_ );
154  }
155 
156  bool operator!=( const const_iterator& other ) {
157  return ( it_ != other.it_ );
158  }
159 
161  it_++;
162  return (*this);
163  }
164 
166  return it_->second();
167  }
168 
170  return it_->second;
171  }
172 
173  private:
174  StructureMap::const_iterator it_; // keep track of my place in a StructureMap
175  }; // class iterator
176 
177  /// @brief Returns an iterator to the start of the members of this container.
178  iterator begin() { return ( iterator( structure_map_.begin() ) ); }
179  /// @brief Returns an iterator to the end of the members of this container.
180  iterator end() { return ( iterator( structure_map_.end() ) ); }
181 
182  const_iterator begin_const() const { return ( const_iterator( structure_map_.begin() ) ); }
183  const_iterator end_const() const { return ( const_iterator( structure_map_.end() ) ); }
184 
185  }; // class RawFileData
186 } // namespace silent
187 } // namespace io
188 } // namespace core
189 
190 #endif