libyui
|
00001 /************************************************************************** 00002 Copyright (C) 2000 - 2010 Novell, Inc. 00003 All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License along 00016 with this program; if not, write to the Free Software Foundation, Inc., 00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 00019 **************************************************************************/ 00020 00021 00022 /*---------------------------------------------------------------------\ 00023 | | 00024 | __ __ ____ _____ ____ | 00025 | \ \ / /_ _/ ___|_ _|___ \ | 00026 | \ V / _` \___ \ | | __) | | 00027 | | | (_| |___) || | / __/ | 00028 | |_|\__,_|____/ |_| |_____| | 00029 | | 00030 | core system | 00031 | (C) SuSE GmbH | 00032 \----------------------------------------------------------------------/ 00033 00034 File: ImplPtr.h 00035 00036 Author: Michael Andres <ma@suse.de> 00037 00038 /-*/ 00039 00040 #ifndef ImplPtr_h 00041 #define ImplPtr_h 00042 00043 #include <boost/noncopyable.hpp> 00044 #include <boost/scoped_ptr.hpp> 00045 00056 template<class _Impl> 00057 class ImplPtr : private boost::noncopyable 00058 { 00059 typedef typename boost::scoped_ptr<_Impl>::unspecified_bool_type unspecified_bool_type; 00060 00061 public: 00062 typedef _Impl element_type; 00063 00064 explicit 00065 ImplPtr( _Impl * impl_r = 0 ) : _impl( impl_r ) {} 00066 00067 public: 00068 void reset( _Impl * impl_r = 0 ) { _impl.reset( impl_r ); } 00069 00070 void swap( ImplPtr rhs ) { _impl.swap( rhs._impl ); } 00071 00072 public: 00073 operator unspecified_bool_type() const { return _impl; } 00074 00075 const _Impl & operator*() const { return *_impl; } 00076 const _Impl * operator->() const { return _impl.get(); } 00077 const _Impl * get() const { return _impl.get(); } 00078 00079 _Impl & operator*() { return *_impl; } 00080 _Impl * operator->() { return _impl.get(); } 00081 _Impl * get() { return _impl.get(); } 00082 00083 private: 00084 boost::scoped_ptr<_Impl> _impl; 00085 }; 00086 00087 template<class _Impl> 00088 inline bool operator==( ImplPtr<_Impl> & lhs, ImplPtr<_Impl> & rhs ) { return lhs.get() == rhs.get(); } 00089 00090 template<class _Impl> 00091 inline bool operator!=( ImplPtr<_Impl> & lhs, ImplPtr<_Impl> & rhs ) { return lhs.get() != rhs.get(); } 00092 00093 template<class _Impl> 00094 inline bool operator< ( ImplPtr<_Impl> & lhs, ImplPtr<_Impl> & rhs ) { return lhs.get() < rhs.get(); } 00095 00096 #endif // ImplPtr_h