chain.hpp

Go to the documentation of this file.
00001 // -*- mode: c++; indent-tabs-mode: nil; -*-
00002 //
00003 //The Biomolecule Toolkit (BTK) is a C++ library for use in the
00004 //modeling, analysis, and design of biological macromolecules.
00005 //Copyright (C) 2006, Tim Robertson <kid50@users.sourceforge.net>
00006 //
00007 //This program is free software; you can redistribute it and/or modify
00008 //it under the terms of the GNU Lesser General Public License as published
00009 //by the Free Software Foundation; either version 2.1 of the License, or (at
00010 //your option) any later version.
00011 //
00012 //This program is distributed in the hope that it will be useful,  but
00013 //WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 //Lesser General Public License for more details.
00016 //
00017 //You should have received a copy of the GNU Lesser General Public License
00018 //along with this program; if not, write to the Free Software Foundation,
00019 //Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00023 
00024 #ifndef BTK_MOLECULES_CHAIN_HPP
00025 #define BTK_MOLECULES_CHAIN_HPP
00026 
00027 #include <btk/core/molecules/atomic_structure.hpp>
00028 
00029 namespace BTK {
00030 namespace MOLECULES {
00031 
00032 template <typename AtomType,
00033           typename ChemicalTypeSystemType,
00034           typename DictionaryType,
00035           typename StorageStrategy = std::vector<AtomType> >
00036 class Chain : 
00037     public AtomicStructure<AtomType,
00038                            ChemicalTypeSystemType,
00039                            DictionaryType,
00040                            StorageStrategy>
00041 {
00042   typedef Chain<AtomType,
00043                 ChemicalTypeSystemType,
00044                 DictionaryType,
00045                 StorageStrategy> self_type;
00046   typedef AtomicStructure<AtomType,
00047                           ChemicalTypeSystemType,
00048                           DictionaryType,
00049                           StorageStrategy> base_type;
00050 public:
00051   IMPORT_ATOMIC_STRUCTURE_TYPES(base_type);
00052 
00053   Chain(self_type const & source) : 
00054     base_type(source), _chain_id(source._chain_id) {}
00055 
00056   virtual ~Chain() {}
00057 
00059   virtual std::ostream & print(std::ostream & os,
00060                                size_type first_atom_num = 1,
00061                                size_type group_num = 1) const 
00062   {
00063     return base_type::print(os,first_atom_num,group_num,_chain_id);
00064   }
00065 
00067   char chain_id() const { return _chain_id; }
00069   void set_chain_id(char ch_id) { _chain_id = ch_id; }
00070 
00071 protected:
00072   
00075 
00076   Chain(size_type n = 0, 
00077         const_reference t = atom_type(),
00078         id_type type = id_type(),
00079         char chain_id = ' ') : 
00080   base_type(n,t,type), _chain_id(chain_id) {}
00081   
00082   template <typename AtomIterator>
00083   Chain(AtomIterator i, AtomIterator j, id_type type, char chain_id) :
00084     base_type(i,j,type), _chain_id(chain_id) {}
00086 
00089   void swap(self_type & b) 
00090   {
00091     base_type::swap(b);
00092     std::swap(_chain_id,b._chain_id);
00093   }
00094 
00097   self_type const & operator=(self_type const & rhs)
00098   {
00099     if (this == &rhs) return *this;
00100     base_type::operator=(rhs);
00101     _chain_id = rhs._chain_id;
00102     return *this;
00103   }
00104 
00110 
00111   bool operator==(self_type const & rhs) const 
00112   {
00113     return (_chain_id == rhs._chain_id && base_type::operator==(rhs));
00114   }
00115 
00116   bool operator!=(self_type const & rhs) const
00117   {
00118     return !(operator==(rhs));
00119   }
00121 
00129   bool operator<(self_type const & rhs) const 
00130   {
00131     if (_chain_id < rhs._chain_id) 
00132       return true;
00133     else if (_chain_id == rhs._chain_id) 
00134       return base_type::operator<(rhs);
00135     else
00136       return false;
00137   }
00138 
00139 private:
00140   char _chain_id;
00141 };
00142 
00143 } // namespace MOLECULES
00144 } // namespace BTK
00145 
00146 #endif

Generated on Sun Jul 15 20:46:25 2007 for BTK Core by  doxygen 1.5.1