00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 }
00144 }
00145
00146 #endif