Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NamedAtomID.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/id/NamedAtomID.hh
11 /// @author Oliver Lange
12 
13 
14 #ifndef INCLUDED_core_id_NamedAtomID_hh
15 #define INCLUDED_core_id_NamedAtomID_hh
16 
17 // Unit headers
19 // AUTO-REMOVED #include <core/id/AtomID.fwd.hh>
20 
21 // C++ headers
22 // AUTO-REMOVED #include <iosfwd>
23 #ifdef WIN32
24 #include <string>
25 #endif
26 
27 #include <core/types.hh>
28 #include <ostream>
29 
30 
31 namespace core {
32 namespace id {
33 
34 
35 /////////////////////////////////////////////////////////////////////////////
36 // NamedAtomID
37 /////////////////////////////////////////////////////////////////////////////
38 
39 // data to uniquely specify an atom
40 // could change -- pointer?
41 
42 /// @brief Atom identifier class
44 {
45 
46 public: // Creation
47 
48  /// @brief Default constructor
49  inline
51  atom_( "" ),
52  rsd_( 0 )
53  {}
54 
55  /// @brief Copy constructor
56  inline
57  NamedAtomID( NamedAtomID const & src ) :
58  atom_( src.atom_ ),
59  rsd_( src.rsd_ )
60  {}
61 
62  /// @brief Property constructor
63  inline
65  std::string const & atom_in,
66  Size const rsd_in
67  ) :
68  atom_( atom_in ),
69  rsd_( rsd_in )
70  {}
71 
72 public: // Properties
73 
74  inline
75  Size
76  rsd() const { return rsd_; }
77 
78  inline
79  Size &
80  rsd() { return rsd_; }
81 
82  inline
83  std::string const&
84  atom() const { return atom_; }
85 
86  inline
87  std::string &
88  atom() { return atom_; }
89 
90  /// @brief Is this id valid?
91  /// @note Must return false for BOGUS_ATOM_ID
92  inline
93  bool
94  valid() const { return ( atom_.size() ) && ( rsd() > 0 ); }
95 
96  std::string to_string() const;
97 
98 public: // Friends
99 
100  friend
101  std::ostream &
102  operator <<(
103  std::ostream & os,
104  NamedAtomID const & a
105  );
106 
107  /// @brief input operator
108  friend std::istream & operator >> ( std::istream & is, NamedAtomID & e );
109 
110  /// @brief a and b are the same atom
111  friend
112  inline
113  bool
115  NamedAtomID const & a,
116  NamedAtomID const & b
117  ) { return a.atom_ == b.atom_ && a.rsd_ == b.rsd_; }
118 
119  /// @brief a and b are different atom
120  friend
121  inline
122  bool
124  NamedAtomID const & a,
125  NamedAtomID const & b
126  ) { return a.atom_ != b.atom_ || a.rsd_ != b.rsd_; }
127 
128  /// @brief a is LOWER than b (e.g., first by smaller residue index number then by smaller atom index number)
129  friend
130  inline
131  bool
133  NamedAtomID const & a,
134  NamedAtomID const & b
135  ) {
136  return ( a.rsd_ < b.rsd_ ||
137  ( a.rsd_ == b.rsd_ && a.atom_ < b.atom_ ) );
138  }
139 
140 private: // Fields
141  /// @brief Atom number within the Residue
143 
144  /// @brief Residue number within the complex
146 }; // NamedAtomID
147 
148 
149 /// @brief Globals
152 
153 } // id
154 } // core
155 
156 #endif