2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
8 As a special exception, if other files instantiate templates or use macros
9 or inline functions from this file, or you compile this file and link it
10 with other works to produce a work based on this file, this file
11 does not by itself cause the resulting work to be covered
12 by the GNU General Public License.
14 However the source code for this file must still be made available
15 in accordance with section (3) of the GNU General Public License.
17 This exception does not invalidate any other reasons why a work based
18 on this file might be covered by the GNU General Public License.
22 * @brief some functions to deal with (smart) pointer
24 * @author Reinhard Pfau \<Reinhard.Pfau@gmx.de\>
25 * @copyright © Copyright 2009 by Intra2net AG
28 #ifndef _ASYNCIO_POINTER_FUNC_HPP_
29 #define _ASYNCIO_POINTER_FUNC_HPP_
31 #include <asyncio_config.hpp>
32 #include <boost/shared_ptr.hpp>
33 #include <boost/enable_shared_from_this.hpp>
34 #ifdef HAVE_LIBI2NCOMMON
35 # include <pointer_func.hpp>
43 #ifdef HAVE_LIBI2NCOMMON
45 // NOTE: this typedef is needed by I2N code; please keep it!
47 typedef I2n::SharedBase SharedBase
52 : public boost::enable_shared_from_this< SharedBase >
55 typedef boost::shared_ptr< SharedBase > PtrType;
59 virtual ~SharedBase() {}
62 boost::shared_ptr< D > get_ptr_as()
66 return boost::shared_dynamic_cast< D >( shared_from_this() );
68 catch( boost::bad_weak_ptr& e )
70 // we ignore this error.
72 return boost::shared_ptr< D >();
75 }; // end of SharedBase
80 } // end of namespace Utils
81 } // end of namespace AsyncIo