diff options
-rw-r--r-- | include/gras/element.hpp | 6 | ||||
-rw-r--r-- | include/gras/element.i | 11 | ||||
-rw-r--r-- | lib/element.cpp | 5 |
3 files changed, 12 insertions, 10 deletions
diff --git a/include/gras/element.hpp b/include/gras/element.hpp index 0bebc14..40a24cf 100644 --- a/include/gras/element.hpp +++ b/include/gras/element.hpp @@ -31,6 +31,12 @@ struct GRAS_API Element : ElementBase, boost::enable_shared_from_this<Element> /*virtual*/ ~Element(void); + /*! + * Check if another element is the same as this one. + * \return true if the rhs is the same as *this. + */ + bool equals(const Element &rhs); + /******************************************************************* * identification interface ******************************************************************/ diff --git a/include/gras/element.i b/include/gras/element.i index be3814e..8f04a3d 100644 --- a/include/gras/element.i +++ b/include/gras/element.i @@ -34,22 +34,13 @@ //////////////////////////////////////////////////////////////////////// // Operator overloads for Element //////////////////////////////////////////////////////////////////////// -%{ - -inline bool gras_element_equal(const gras::Element &lhs, const gras::Element &rhs) -{ - return lhs.get() == rhs.get(); -} - -%} - %extend gras::Element { %insert("python") %{ def __eq__(self, rhs): if not isinstance(rhs, Element): return False - return gras_element_equal(self, rhs) + return self.equals(rhs) def __str__(self): return self.to_string() diff --git a/lib/element.cpp b/lib/element.cpp index f291310..6736011 100644 --- a/lib/element.cpp +++ b/lib/element.cpp @@ -38,6 +38,11 @@ ElementImpl::~ElementImpl(void) if (this->block) this->block_cleanup(); } +bool Element::equals(const Element &rhs) +{ + return this->get() == rhs.get(); +} + long Element::unique_id(void) const { return (*this)->unique_id; |