Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ElementSet.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/chemical/ElementSet.hh
11 /// @author P. Douglas Renfrew (renfrew@unc.edu)
12 
13 
14 #ifndef INCLUDED_core_chemical_ElementSet_hh
15 #define INCLUDED_core_chemical_ElementSet_hh
16 
17 
18 // Unit headers
20 // AUTO-REMOVED #include <core/chemical/Element.hh>
21 
22 // Project headers
23 
24 // Utility headers
25 // AUTO-REMOVED #include <utility/vector1.hh>
26 #include <utility/exit.hh>
27 #include <utility/pointer/ReferenceCount.hh>
28 
29 // C++ headers
30 // Commented by inclean daemon #include <string>
31 #include <map>
32 
33 #include <utility/vector1_bool.hh>
34 
35 #include <core/types.hh>
37 
38 
39 
40 
41 namespace core {
42 namespace chemical {
43 
44 
45 /// @brief A set of Elements
46 ///
47 /// @details This class contains a vector of pointers each of which points to an
48 /// Element and the vector index is looked up by an element_name string
49 /// in a map.
50 ///
52 
53 public:
54  ElementSet();
55  virtual ~ElementSet();
56 
57  /// @brief Number of elements in the set
58  Size
59  n_elements() const
60  {
61  return elements_.size();
62  }
63 
64 
65  /// @brief Check if there is an element_type associated with an element_symbol string
66  bool
67  contains_element_type( std::string const & element_symbol ) const
68  {
69  std::map< std::string, int >::const_iterator
70  iter( element_index_.find( element_symbol ) );
71  return iter != element_index_.end();
72  }
73 
74 
75  /// @brief Lookup the element index by the element_symbol string
76  int
77  element_index( std::string const & element_symbol ) const
78  {
79  std::map< std::string, int >::const_iterator
80  iter( element_index_.find( element_symbol ) );
81  if ( iter == element_index_.end() ) {
82  utility_exit_with_message("unrecognized element_symbol "+element_symbol);
83  }
84  return iter->second;
85  }
86 
87 
88  /// @brief Lookup an Element by 1-based indexing
89  Element const &
90  operator[] ( Size const index ) const
91  {
92  return *( elements_[ index ] );
93  }
94 
95 
96  /// @brief Load the ElementSet from a file
97  void
98  read_file( std::string const & filename );
99 
100  /// @brief Print all of the symbols of all of the Elements in the set. Usefull for debuging.
101  void
102  print_all_types();
103 
104 
105  // data
106 private:
107 
108  /// @brief element_index_ lookup map
109  ///
110  /// @details element_index_ allows lookup of the element by its symbol
111  std::map< std::string, int > element_index_;
112 
113  /// @brief a collection of Elements,
114  ///
115  /// @details Element has data of atom properties, and it can be
116  /// looked up by element_index.
118 
119 };
120 
121 } // chemical
122 } // core
123 
124 #endif // INCLUDED_core_chemical_ElementSet_HH