_Tp object calling a custom Dispose function when the last AutoDispose handle to it is destroyed or reset.
More...
#include <AutoDispose.h>
Public Types | |
| typedef boost::call_traits < _Tp >::param_type | param_type |
| typedef boost::call_traits < _Tp >::reference | reference |
| typedef boost::call_traits < _Tp > ::const_reference | const_reference |
| typedef _Tp | value_type |
| typedef boost::call_traits < _Tp >::value_type | result_type |
| typedef function < void(param_type)> | Dispose |
| Dispose function signatue. | |
Public Member Functions | |
| AutoDispose () | |
| Default Ctor using default constructed value and no dispose function. | |
| AutoDispose (param_type value_r) | |
| Ctor taking value and no dispose function. | |
| AutoDispose (param_type value_r, const Dispose &dispose_r) | |
| Ctor taking value and dispose function. | |
| operator reference () const | |
Provide implicit conversion to _Tp&. | |
| reference | value () const |
Reference to the _Tp object. | |
| reference | operator * () const |
Reference to the _Tp object. | |
| value_type * | operator-> () const |
Pointer to the _Tp object (asserted to be != NULL). | |
| void | reset () |
| Reset to default Ctor values. | |
| void | swap (AutoDispose &rhs) |
| Exchange the contents of two AutoDispose objects. | |
| const Dispose & | getDispose () const |
| Return the current dispose function. | |
| void | setDispose (const Dispose &dispose_r) |
| Set a new dispose function. | |
| void | resetDispose () |
| Set no dispose function. | |
| void | swapDispose (Dispose &dispose_r) |
| Exchange the dispose function. | |
Private Attributes | |
| shared_ptr< Impl > | _pimpl |
Related Functions | |
| (Note that these are not member functions.) | |
| template<class _Tp> | |
| std::ostream & | operator<< (std::ostream &str, const AutoDispose< _Tp > &obj) |
<_Tp> Stream output of the _Tp object. | |
Classes | |
| struct | Impl |
_Tp object calling a custom Dispose function when the last AutoDispose handle to it is destroyed or reset.
AutoDispose object does not apply to the stored _Tp object. If the stored _Tp object should be immutable, you should use AutoDispose<const _Tp>.struct FileCache { Pathname getFile(); void releaseFile( const Pathname & ); }; static FileCache cache; void unlink( const Pathname & file_r ); AutoDispose<const Pathname> provideFile( ... ) { if ( file_is_in_cache ) { // will call 'cache.releaseFile( file )' return AutoDispose<const Pathname>( cache.getFile(), bind( &FileCache::releaseFile, ref(cache), _1 ) ); } else if ( file_is_temporary ) { // will call 'unlink( file )' return AutoDispose<const Pathname>( file, unlink ); } else if ( file_is_permanent ) { // will do nothing. return AutoDispose<const Pathname>( file ); } else { // will do nothing. return AutoDispose<const Pathname>(); } }
Exception safe handling of temporary files:
void provideFileAt( const Pathname & destination ) { AutoDispose<const Pathname> guard( destination, unlink ); // Any exception here will lead to 'unlink( destination )' // ... // On success: reset the dispose function to NOOP. guard.resetDispose(); }
Definition at line 92 of file AutoDispose.h.
| typedef boost::call_traits<_Tp>::param_type zypp::AutoDispose< _Tp >::param_type |
Definition at line 95 of file AutoDispose.h.
| typedef boost::call_traits<_Tp>::reference zypp::AutoDispose< _Tp >::reference |
Definition at line 96 of file AutoDispose.h.
| typedef boost::call_traits<_Tp>::const_reference zypp::AutoDispose< _Tp >::const_reference |
Definition at line 97 of file AutoDispose.h.
| typedef _Tp zypp::AutoDispose< _Tp >::value_type |
Definition at line 98 of file AutoDispose.h.
| typedef boost::call_traits<_Tp>::value_type zypp::AutoDispose< _Tp >::result_type |
Definition at line 99 of file AutoDispose.h.
| typedef function<void ( param_type )> zypp::AutoDispose< _Tp >::Dispose |
| zypp::AutoDispose< _Tp >::AutoDispose | ( | ) | [inline] |
Default Ctor using default constructed value and no dispose function.
Definition at line 107 of file AutoDispose.h.
Referenced by zypp::AutoDispose< _Tp >::reset().
| zypp::AutoDispose< _Tp >::AutoDispose | ( | param_type | value_r | ) | [inline] |
| zypp::AutoDispose< _Tp >::AutoDispose | ( | param_type | value_r, | |
| const Dispose & | dispose_r | |||
| ) | [inline] |
| zypp::AutoDispose< _Tp >::operator reference | ( | ) | const [inline] |
Provide implicit conversion to _Tp&.
Definition at line 124 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::_pimpl.
| reference zypp::AutoDispose< _Tp >::value | ( | ) | const [inline] |
Reference to the _Tp object.
Definition at line 128 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::_pimpl.
Referenced by zypp::target::CommitPackageCacheReadAhead::doCacheLastInteractive(), zypp::repo::doProvideScript(), zypp::repo::doProvideSrcPackage(), zypp::target::CommitPackageCacheReadAhead::get(), and zypp::target::CommitPackageCache::Impl::sourceProvidePackage().
| reference zypp::AutoDispose< _Tp >::operator * | ( | ) | const [inline] |
Reference to the _Tp object.
Definition at line 132 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::_pimpl.
| value_type* zypp::AutoDispose< _Tp >::operator-> | ( | ) | const [inline] |
Pointer to the _Tp object (asserted to be != NULL).
Definition at line 136 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::_pimpl.
| void zypp::AutoDispose< _Tp >::reset | ( | ) | [inline] |
Reset to default Ctor values.
Definition at line 140 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::AutoDispose().
| void zypp::AutoDispose< _Tp >::swap | ( | AutoDispose< _Tp > & | rhs | ) | [inline] |
Exchange the contents of two AutoDispose objects.
Definition at line 144 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::_pimpl.
| const Dispose& zypp::AutoDispose< _Tp >::getDispose | ( | ) | const [inline] |
Return the current dispose function.
Definition at line 149 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::_pimpl.
| void zypp::AutoDispose< _Tp >::setDispose | ( | const Dispose & | dispose_r | ) | [inline] |
Set a new dispose function.
Definition at line 153 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::_pimpl.
Referenced by zypp::AutoDispose< _Tp >::resetDispose().
| void zypp::AutoDispose< _Tp >::resetDispose | ( | ) | [inline] |
Set no dispose function.
Definition at line 157 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::setDispose().
Referenced by zypp::applydeltarpm::provide().
| void zypp::AutoDispose< _Tp >::swapDispose | ( | Dispose & | dispose_r | ) | [inline] |
Exchange the dispose function.
+
Definition at line 161 of file AutoDispose.h.
References zypp::AutoDispose< _Tp >::_pimpl.
| std::ostream & operator<< | ( | std::ostream & | str, | |
| const AutoDispose< _Tp > & | obj | |||
| ) | [related] |
<_Tp> Stream output of the _Tp object.
Definition at line 189 of file AutoDispose.h.
References zypp::solver::detail::str.
shared_ptr<Impl> zypp::AutoDispose< _Tp >::_pimpl [private] |
Definition at line 183 of file AutoDispose.h.
Referenced by zypp::AutoDispose< _Tp >::getDispose(), zypp::AutoDispose< _Tp >::operator *(), zypp::AutoDispose< _Tp >::operator reference(), zypp::AutoDispose< _Tp >::operator->(), zypp::AutoDispose< _Tp >::setDispose(), zypp::AutoDispose< _Tp >::swap(), zypp::AutoDispose< _Tp >::swapDispose(), and zypp::AutoDispose< _Tp >::value().
1.5.3