12 #ifndef ZYPP_AUTODISPOSE_H
13 #define ZYPP_AUTODISPOSE_H
16 #include <boost/call_traits.hpp>
95 typedef typename boost::call_traits<_Tp>::param_type
param_type;
96 typedef typename boost::call_traits<_Tp>::reference
reference;
99 typedef typename boost::call_traits<_Tp>::value_type
result_type;
103 typedef function<void ( param_type )>
Dispose;
130 {
return _pimpl->_value; }
134 {
return _pimpl->_value; }
138 {
return _pimpl->_value; }
142 {
return &
_pimpl->_value; }
155 {
return _pimpl->_dispose; }
159 {
_pimpl->_dispose = dispose_r; }
167 {
_pimpl->_dispose.swap( dispose_r ); }
194 inline std::ostream & operator<<( std::ostream & str, const AutoDispose<_Tp> & obj )
195 {
return str << obj.value(); }
200 #endif // ZYPP_AUTODISPOSE_H
boost::call_traits< _Tp >::param_type param_type
void resetDispose()
Set no dispose function.
boost::call_traits< _Tp >::value_type result_type
reference value() const
Reference to the _Tp object.
AutoDispose()
Default Ctor using default constructed value and no dispose function.
void reset()
Reset to default Ctor values.
AutoDispose(const Dispose &dispose_r)
Ctor taking dispose function and using default constructed value.
void swapDispose(Dispose &dispose_r)
Exchange the dispose function.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
boost::call_traits< _Tp >::reference reference
Impl(param_type value_r, const Dispose &dispose_r)
AutoDispose(param_type value_r)
Ctor taking value and no dispose function.
value_type * operator->() const
Pointer to the _Tp object (asserted to be != NULL).
void swap(AutoDispose &rhs)
Exchange the contents of two AutoDispose objects.
function< void(param_type)> Dispose
Dispose function signatue.
boost::call_traits< _Tp >::const_reference const_reference
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
Reference counted access to a _Tp object calling a custom Dispose function when the last AutoDispose ...
shared_ptr< Impl > _pimpl
AutoDispose(param_type value_r, const Dispose &dispose_r)
Ctor taking value and dispose function.
const Dispose & getDispose() const
Return the current dispose function.
reference operator*() const
Reference to the _Tp object.