00001 // Copyright (c) 2009-2010 INRIA Sophia-Antipolis (France). 00002 // All rights reserved. 00003 // 00004 //This file is part of ESBTL. 00005 // 00006 //ESBTL is free software: you can redistribute it and/or modify 00007 //it under the terms of the GNU General Public License as published by 00008 //the Free Software Foundation, either version 3 of the License, or 00009 //(at your option) any later version. 00010 // 00011 //ESBTL is distributed in the hope that it will be useful, 00012 //but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 //GNU General Public License for more details. 00015 // 00016 //You should have received a copy of the GNU General Public License 00017 //along with ESBTL. If not, see <http://www.gnu.org/licenses/>. 00018 // 00019 // 00020 //Additional permission under GNU GPL version 3 section 7 00021 // 00022 //If you modify this Library, or any covered work, by linking or 00023 //combining it with CGAL (or a modified version of that library), the 00024 //licensors of this Library grant you additional permission to convey 00025 //the resulting work. Corresponding Source for a non-source form of 00026 //such a combination shall include the source code for the parts of CGAL 00027 //used as well as that of the covered work. 00028 // 00029 // 00030 // 00031 // Author(s) : Sébastien Loriot 00032 00033 00034 #include <set> 00035 00036 #ifndef ESBTL_ATOM_SELECTORS_H 00037 #define ESBTL_ATOM_SELECTORS_H 00038 00053 namespace ESBTL{ 00054 00058 struct Select_by_resname{ 00059 std::string name; 00061 Select_by_resname(){}; //needed by selected_atom_iterator::end and default constructor 00066 Select_by_resname(const std::string& str):name(str){} 00072 template <class Atom> 00073 bool operator()(const Atom& atom) const { 00074 return get_residue_name(atom)==name; 00075 } 00076 }; 00077 00078 00082 struct Select_by_atmname{ 00083 std::string name; 00085 Select_by_atmname(){}; //needed by selected_atom_iterator::end and default constructor 00086 00091 Select_by_atmname(const std::string& str):name(str){} 00092 00098 template <class Atom> 00099 bool operator()(const Atom& atom) const { 00100 return get_atom_name(atom)==name; 00101 } 00102 }; 00103 00107 struct Select_by_element{ 00108 std::string name; 00110 Select_by_element(){}; //needed by selected_atom_iterator::end and default constructor 00115 Select_by_element(const std::string& str):name(str){} 00121 template <class Atom> 00122 bool operator()(const Atom& atom) const { 00123 return get_element(atom)==name; 00124 } 00125 }; 00126 00130 class Select_by_chainids{ 00131 std::set<char> chains; 00132 public: 00134 Select_by_chainids(){}; //needed by selected_atom_iterator::end and default constructor 00140 Select_by_chainids(const std::string& chs){ 00141 for (unsigned i=0;i!=chs.size();++i) 00142 chains.insert(chs[i]); 00143 } 00144 00150 template <class Atom> 00151 bool operator()(const Atom& atom) const { 00152 return chains.find( get_chain_identifier( atom ) ) != chains.end(); 00153 } 00154 }; 00155 00156 } //namespace ESBTL 00157 00158 #endif //ESBTL_ATOM_SELECTORS_H