summaryrefslogtreecommitdiff
path: root/include/gras/detail/element.hpp
blob: 35033e1f2a7a675baa70ff4c99c4525387169a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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 <typename T>
    inline Element::Element(const boost::shared_ptr<T> &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*/