12#ifndef ZYPP_AUTODISPOSE_H
13#define ZYPP_AUTODISPOSE_H
16#include <boost/call_traits.hpp>
18#include <zypp-core/base/NonCopyable.h>
19#include <zypp-core/base/PtrTypes.h>
20#include <zypp-core/base/Function.h>
21#include <zypp-core/Pathname.h>
96 typedef typename boost::call_traits<Tp>::param_type
param_type;
97 typedef typename boost::call_traits<Tp>::reference
reference;
98 typedef typename boost::call_traits<Tp>::const_reference
const_reference;
100 typedef typename boost::call_traits<Tp>::value_type
result_type;
103 using dispose_param_type =
typename std::conditional< std::is_pointer<Tp>::value || std::is_integral<Tp>::value, Tp
const,
reference >::type;
144 {
return _pimpl->_value; }
148 {
return _pimpl->_value; }
152 {
return _pimpl->_value; }
156 {
return &
_pimpl->_value; }
173 {
return _pimpl->_dispose; }
190 template <
typename T>
194 template <
typename T,
typename D>
212 class AutoDispose<void>
242 {
return _pimpl->_dispose; }
292 inline std::ostream &
operator<<( std::ostream &
str,
const AutoDispose<Tp> & obj )
293 {
return str << obj.value(); }
301 struct AutoFD :
public AutoDispose<int>
312 struct AutoFILE :
public AutoDispose<FILE*>
322 template <
typename Tp>
323 struct AutoFREE :
public AutoDispose<Tp*>
330 struct AutoFREE<void> :
public AutoDispose<void*>
RepoManager implementation.
value_type * operator->() const
Pointer to the Tp object (asserted to be != NULL).
reference value() const
Reference to the Tp object.
const Dispose & getDispose() const
Return the current dispose function.
void resetDispose()
Set no dispose function.
function< void(dispose_param_type)> Dispose
Dispose function signatue.
AutoDispose()
Default Ctor using default constructed value and no dispose function.
reference operator*() const
Reference to the Tp object.
void reset()
Reset to default Ctor values.
shared_ptr< Impl > _pimpl
void swap(AutoDispose &rhs)
Exchange the contents of two AutoDispose objects.
void swapDispose(Dispose &dispose_r)
Exchange the dispose function.
bool unique() const
Returns true if this is the only AutoDispose instance managing the current data object.
boost::call_traits< Tp >::param_type param_type
boost::call_traits< Tp >::reference reference
boost::call_traits< Tp >::const_reference const_reference
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
boost::call_traits< Tp >::value_type result_type
typename std::conditional< std::is_pointer< Tp >::value||std::is_integral< Tp >::value, Tp const, reference >::type dispose_param_type
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
AutoDispose< void > Deferred
AutoDispose< void > OnScopeExit
AutoFILE(FILE *file_r=nullptr)
AutoFREE(Tp *ptr_r=nullptr)