From 8c3b96b2b7c9bfda6b19fd96a4305ded8d52a164 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 21 Mar 2013 20:11:08 -0700 Subject: gras: move element details into header --- include/gras/detail/element.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 include/gras/detail/element.hpp (limited to 'include/gras/detail') diff --git a/include/gras/detail/element.hpp b/include/gras/detail/element.hpp new file mode 100644 index 0000000..35033e1 --- /dev/null +++ b/include/gras/detail/element.hpp @@ -0,0 +1,27 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_DETAIL_ELEMENT_HPP +#define INCLUDED_GRAS_DETAIL_ELEMENT_HPP + +namespace gras +{ + template + inline Element::Element(const boost::shared_ptr &elem) + { + *this = elem->shared_to_element(); + } + + //! Convert a shared ptr of a derived class to an Element + inline Element &Element::shared_to_element(void) + { + try + { + this->weak_self = this->shared_from_this(); + } + catch(...){} + return *this; + } + +} //namespace gras + +#endif /*INCLUDED_GRAS_DETAIL_ELEMENT_HPP*/ -- cgit