diff --git a/modules/gfx/src/impl/entity_detail.cc b/modules/gfx/src/impl/entity_detail.cc index 1225df45778087ba1324815f30f8ea2188bc590b..572de5bb7e2b995fba33d204cf3e7745110a42f5 100644 --- a/modules/gfx/src/impl/entity_detail.cc +++ b/modules/gfx/src/impl/entity_detail.cc @@ -43,9 +43,9 @@ void GfxView::AddAtom(const AtomView& av) AtomEntry ae(a,default_radius, a.GetRadius(), GfxObj::Ele2Color(a.GetElement())); - atom_map[a.GetHashCode()]=ae; + atom_map[a.GetHandle().GetHashCode()]=ae; if(av.GetBondCount()==0) { - orphan_atom_list.push_back(a.GetHashCode()); + orphan_atom_list.push_back(a.GetHandle().GetHashCode()); } } diff --git a/modules/mol/base/pymod/export_atom.cc b/modules/mol/base/pymod/export_atom.cc index 83f2adc0648de4b6eaacccadfba7dbf0337d812b..c2133beb95fcc8cf280db30c176a075824eedf68 100644 --- a/modules/mol/base/pymod/export_atom.cc +++ b/modules/mol/base/pymod/export_atom.cc @@ -42,8 +42,6 @@ void export_Atom() .add_property("qualified_name", &AtomBase::GetQualifiedName) .def("IsValid", &AtomBase::IsValid) .def(self_ns::str(self)) - .add_property("hash_code", &AtomBase::GetHashCode) - .def("GetHashCode", &AtomBase::GetHashCode) .def("GetAtomProps", &AtomBase::GetAtomProps, return_value_policy<copy_const_reference>()) .def("SetAtomProps", &AtomBase::SetAtomProps, args("prop")) @@ -86,10 +84,12 @@ void export_Atom() .add_property("handle", &AtomHandle::GetHandle) .add_property("entity", &AtomHandle::GetEntity) .def("GetBondPartners", &AtomHandle::GetBondPartners) + .def("GetHashCode", &AtomHandle::GetHashCode) .def("FindBondToAtom", &AtomHandle::FindBondToAtom, args("other_atom")) .def(self==self) .def(self!=self) .def("__hash__", &AtomHandle::GetHashCode) + .add_property("hash_code", &AtomHandle::GetHashCode) ; class_<AtomHandleList>("AtomHandleList", no_init) diff --git a/modules/mol/base/pymod/export_atom_view.cc b/modules/mol/base/pymod/export_atom_view.cc index af2dd063b8ea7db1f510ec39aca5df7ad7fce705..036a87ae056ded83b3f30b4803315aa9f3295a89 100644 --- a/modules/mol/base/pymod/export_atom_view.cc +++ b/modules/mol/base/pymod/export_atom_view.cc @@ -43,6 +43,9 @@ void export_AtomView() .def("GetHandle", &AtomView::GetHandle) .def("GetBondCount", &AtomView::GetBondCount) .def("GetBondList", &AtomView::GetBondList) + .def("GetHashCode", &AtomView::GetHashCode) + .def("__hash__", &AtomView::GetHashCode) + .add_property("hash_code", &AtomView::GetHashCode) .def("GetBondPartners", &AtomView::GetBondPartners) ; class_<AtomViewList>("AtomViewList", init<>()) diff --git a/modules/mol/base/src/atom_base.cc b/modules/mol/base/src/atom_base.cc index 8eaff3164a27365f42b981a80495e6eb1c9f93f1..2818844b012bb0ac1d8ef0d2f088fb7435128434 100644 --- a/modules/mol/base/src/atom_base.cc +++ b/modules/mol/base/src/atom_base.cc @@ -120,12 +120,6 @@ void AtomBase::CheckValidity() const throw InvalidHandle(); } -long AtomBase::GetHashCode() const -{ - this->CheckValidity(); - return reinterpret_cast<long>(Impl().get()); -} - std::ostream& operator<<(std::ostream& os, const AtomBase& atom) { if (atom.IsValid()) { diff --git a/modules/mol/base/src/atom_base.hh b/modules/mol/base/src/atom_base.hh index 142f1a9db2acab1949bef593ff7a99b5715230c1..9777aea714732f090c4b2def487086e4031ad26f 100644 --- a/modules/mol/base/src/atom_base.hh +++ b/modules/mol/base/src/atom_base.hh @@ -153,11 +153,6 @@ public: /// \brief get atom implementation impl::AtomImplPtr& Impl(); - /// \brief Get unique identifier for atom - /// - /// Get hash code that uniquely identifies every atom. The hash code is - /// identical for all atom views pointing to a given atom. - long GetHashCode() const; protected: GenericPropContainerImpl* GpImpl(); diff --git a/modules/mol/base/src/atom_handle.cc b/modules/mol/base/src/atom_handle.cc index 486441683eb4deb5913d8830ae9aba18d1cce020..61c975724e70f6c913321947ff31e406133aa5a8 100644 --- a/modules/mol/base/src/atom_handle.cc +++ b/modules/mol/base/src/atom_handle.cc @@ -116,6 +116,12 @@ AtomHandle AtomHandle::GetHandle() const return *this; } +long AtomHandle::GetHashCode() const +{ + this->CheckValidity(); + return reinterpret_cast<long>(Impl().get()); +} + }} // ns diff --git a/modules/mol/base/src/atom_handle.hh b/modules/mol/base/src/atom_handle.hh index 7d817f8e169a7f1f38581b41a53697bc0bad2a66..6ea9094c0db51dab69bc7c46b8a5913c2402404b 100644 --- a/modules/mol/base/src/atom_handle.hh +++ b/modules/mol/base/src/atom_handle.hh @@ -81,6 +81,13 @@ public: /// /// Useful for duck-typing in Python and templated code. AtomHandle GetHandle() const; + + /// \brief Get unique identifier for atom + /// + /// Get hash code that uniquely identifies every atom. The hash code is + /// identical for all atom views pointing to a given atom. + long GetHashCode() const; + bool operator==(const AtomHandle& ref) const; bool operator!=(const AtomHandle& ref) const; diff --git a/modules/mol/base/src/atom_view.cc b/modules/mol/base/src/atom_view.cc index 25518778e9164600b08b817e17c48bf3cbb4a0c3..5811a2d5567ea3db1de2ebe8eede8fb4c9a7c631 100644 --- a/modules/mol/base/src/atom_view.cc +++ b/modules/mol/base/src/atom_view.cc @@ -115,7 +115,7 @@ mol::AtomViewList AtomView::GetBondPartners() const mol::AtomViewList avl; mol::BondHandleList::const_iterator i; for (i=data_->bonds.begin();i!=data_->bonds.end();++i) { - if (i->GetFirst()!=*this) { + if (i->GetFirst().GetHandle()!=this->GetHandle()) { avl.push_back(this->GetEntity().FindAtom(i->GetFirst())); } else { avl.push_back(this->GetEntity().FindAtom(i->GetSecond())); @@ -156,7 +156,13 @@ void AtomView::RemoveBondInternal(const BondHandle& bond) data_->bonds.erase(i); } } - + +long AtomView::GetHashCode() const +{ + this->CheckValidity(); + return reinterpret_cast<long>(data_.get()); +} + }} // ns diff --git a/modules/mol/base/src/atom_view.hh b/modules/mol/base/src/atom_view.hh index ad65accc6f155ee28c54248b9178fb2b502fb563..a9e2d9937986b83b3b10d6e547afe2b90c1c6e53 100644 --- a/modules/mol/base/src/atom_view.hh +++ b/modules/mol/base/src/atom_view.hh @@ -69,6 +69,11 @@ public: void Apply(EntityVisitor& visitor); void Apply(EntityViewVisitor& visitor); + /// \brief get unique id + /// + /// The unique id is the same for all AtomViews pointing to the same atom + /// view data. + long GetHashCode() const; bool operator==(const AtomView& rhs) const; bool operator!=(const AtomView& rhs) const; protected: diff --git a/modules/mol/base/src/coord_source.cc b/modules/mol/base/src/coord_source.cc index 9b9f853e32e18e1f237a98458f7bfc85e24545ea..0afa3597dacfba19e28d790f0a606d7311256877 100644 --- a/modules/mol/base/src/coord_source.cc +++ b/modules/mol/base/src/coord_source.cc @@ -95,7 +95,7 @@ void CoordSource::CaptureInto(int pos) e=atoms_.end(); i!=e; ++i) { coords.push_back(i->GetPos()); } - if(pos<0 || pos>=GetFrameCount()) { + if(pos<0 || pos>=static_cast<int>(this->GetFrameCount())) { this->AddFrame(coords); } else { this->InsertFrame(pos,coords); diff --git a/modules/mol/base/tests/test_view.cc b/modules/mol/base/tests/test_view.cc index 33bda815dc7a85e6039bd3dcf4d93b33db7777c7..26399e10e1c240182d87f59a453a605d69dd3902 100644 --- a/modules/mol/base/tests/test_view.cc +++ b/modules/mol/base/tests/test_view.cc @@ -77,6 +77,17 @@ BOOST_AUTO_TEST_CASE(gen_full_view) BOOST_CHECK_EQUAL(avl[1].GetBondCount(),2); BOOST_CHECK_EQUAL(avl[2].GetBondCount(),2); BOOST_CHECK_EQUAL(avl[3].GetBondCount(),1); + + mol::AtomView av1=avl[0]; + mol::AtomView av2=avl[1]; + + BOOST_CHECK(av1!=av2); + BOOST_CHECK(av1.GetHashCode()!=av2.GetHashCode()); + BOOST_CHECK(av1.GetHandle().GetHashCode()!=av1.GetHashCode()); + + mol::AtomView av3=av1; + BOOST_CHECK(av1==av3); + BOOST_CHECK_EQUAL(av1.GetHashCode(), av3.GetHashCode()); } BOOST_AUTO_TEST_SUITE_END() diff --git a/modules/seq/base/pymod/export_sequence.cc b/modules/seq/base/pymod/export_sequence.cc index ce0e19864e6e6d4ee182b4f74391f31c32a078bf..0eb5ce9f29eae682b494d5ffd2cb73f1b981fded 100644 --- a/modules/seq/base/pymod/export_sequence.cc +++ b/modules/seq/base/pymod/export_sequence.cc @@ -38,7 +38,6 @@ using namespace ost; using namespace ost::seq; using namespace boost::python; - namespace { void (SequenceHandle::*attach_one)(const mol::EntityView&)=&SequenceHandle::AttachView;