13#ifndef ZYPP_BASE_PTRTYPES_H 
   14#define ZYPP_BASE_PTRTYPES_H 
   20#include <boost/scoped_ptr.hpp> 
   21#include <boost/shared_ptr.hpp> 
   22#include <boost/weak_ptr.hpp> 
   23#include <boost/intrusive_ptr.hpp> 
   32    std::string 
form( 
const char * format, ... ) __attribute__ ((format (printf, 1, 2)));
 
   90    using boost::scoped_ptr;
 
   93    using boost::shared_ptr;
 
   96    using boost::weak_ptr;
 
   99    using boost::intrusive_ptr;
 
  101    template<
typename T, 
typename... Args>
 
  108    using boost::static_pointer_cast;
 
  110    using boost::const_pointer_cast;
 
  112    using boost::dynamic_pointer_cast;
 
  133  inline std::ostream & 
operator<<( std::ostream & str, 
const zypp::shared_ptr<D> & obj )
 
  137    return str << std::string(
"NULL");
 
  141  inline std::ostream & 
operator<<( std::ostream & 
str, 
const zypp::shared_ptr<void> & obj )
 
  145    return str << std::string(
"NULL");
 
 
  150  inline std::ostream & dumpOn( std::ostream & 
str, 
const zypp::shared_ptr<D> & obj )
 
  153      return dumpOn( 
str, *obj );
 
  154    return str << std::string(
"NULL");
 
  158  inline std::ostream & 
dumpOn( std::ostream & 
str, 
const zypp::shared_ptr<void> & obj )
 
  159  { 
return str << obj; }
 
 
  163  inline std::ostream & 
operator<<( std::ostream & 
str, 
const zypp::intrusive_ptr<D> & obj )
 
  167    return str << std::string(
"NULL");
 
  171  inline std::ostream & 
dumpOn( std::ostream & str, 
const zypp::intrusive_ptr<D> & obj )
 
  174      return dumpOn( str, *obj );
 
  175    return str << std::string(
"NULL");
 
  203          { 
return !ptr_r || ptr_r.unique(); }
 
 
  205          { 
return !ptr_r || ptr_r.unique(); }
 
 
  208          { 
return ptr_r.use_count(); }
 
 
  210          { 
return ptr_r.use_count(); }
 
 
 
  220          { 
return !ptr_r || (ptr_r->refCount() <= 1); }
 
 
  222          { 
return !ptr_r || (ptr_r->refCount() <= 1); }
 
 
  225          { 
return ptr_r ? ptr_r->refCount() : 0; }
 
 
  227          { 
return ptr_r ? ptr_r->refCount() : 0; }
 
 
 
  242          { 
return ptr_r ? 1 : 0; }
 
 
  244          { 
return ptr_r ? 1 : 0; }
 
 
 
 
  291    template<
class D, 
class DTraits = rw_po
inter::Shared<D> >
 
  317        { 
reset(); 
return *
this; }
 
 
  322        void reset( 
typename PtrType::element_type * dptr )
 
 
  326        { 
_dptr.swap( rhs._dptr ); }
 
 
  329        { 
_dptr.swap( rhs ); }
 
 
  332        { 
return _dptr.get() != 
nullptr; }
 
 
  338        { 
return _dptr.operator->(); }
 
 
  341        { 
return _dptr.get(); }
 
 
  347        { 
return _dptr.operator->(); }
 
 
  350        { 
return _dptr.get(); }
 
 
  354        { 
return DTraits().unique( 
_dptr ); }
 
 
  357        { 
return DTraits().use_count( 
_dptr ); }
 
 
 
  378    template<
class D, 
class DPtr>
 
  383        return str << std::string(
"NULL");
 
 
  387    template<
class D, 
class DPtr>
 
  389      { 
return( lhs.
get() == rhs.
get() ); }
 
 
  391    template<
class D, 
class DPtr>
 
  393      { 
return( lhs.
get() == rhs.get() ); }
 
 
  395    template<
class D, 
class DPtr>
 
  397      { 
return( lhs.get() == rhs.
get() ); }
 
 
  399    template<
class D, 
class DPtr>
 
  401      { 
return( lhs.
get() == rhs.get() ); }
 
 
  403    template<
class D, 
class DPtr>
 
  405      { 
return( lhs.get() == rhs.
get() ); }
 
 
  407    template<
class D, 
class DPtr>
 
  409      { 
return( lhs.
get() == 
nullptr ); }
 
 
  411    template<
class D, 
class DPtr>
 
  413      { 
return( 
nullptr == rhs.
get() ); }
 
 
  417    template<
class D, 
class DPtr>
 
  419      { 
return ! ( lhs == rhs ); }
 
 
  421    template<
class D, 
class DPtr>
 
  423      { 
return ! ( lhs == rhs ); }
 
 
  425    template<
class D, 
class DPtr>
 
  427      { 
return ! ( lhs == rhs ); }
 
 
  429    template<
class D, 
class DPtr>
 
  431      { 
return ! ( lhs == rhs ); }
 
 
  433    template<
class D, 
class DPtr>
 
  435      { 
return ! ( lhs == rhs ); }
 
 
  437    template<
class D, 
class DPtr>
 
  439      { 
return( lhs.
get() != 
nullptr ); }
 
 
  441    template<
class D, 
class DPtr>
 
  443      { 
return( 
nullptr != rhs.
get() ); }
 
 
  454      { 
return rhs->
clone(); }
 
 
  467    template<
class D, 
class DTraits = rw_po
inter::Shared<D> >
 
  492        { 
reset(); 
return *
this; }
 
 
  501        void reset( 
typename PtrType::element_type * dptr )
 
 
  505        { 
_dptr.swap( rhs._dptr ); }
 
 
  508        { 
_dptr.swap( rhs ); }
 
 
  511        { 
return _dptr.get() != 
nullptr; }
 
 
  517        { 
return _dptr.operator->(); }
 
 
  520        { 
return _dptr.get(); }
 
 
  533        { 
return DTraits().unique( 
_dptr ); }
 
 
  536        { 
return DTraits().use_count( 
_dptr ); }
 
 
 
  565    template<
class D, 
class DPtr>
 
  570        return str << std::string(
"NULL");
 
 
  574    template<
class D, 
class DPtr>
 
  576      { 
return( lhs.
get() == rhs.
get() ); }
 
 
  578    template<
class D, 
class DPtr>
 
  580      { 
return( lhs.
get() == rhs.get() ); }
 
 
  582    template<
class D, 
class DPtr>
 
  584      { 
return( lhs.get() == rhs.
get() ); }
 
 
  586    template<
class D, 
class DPtr>
 
  588      { 
return( lhs.
get() == rhs.get() ); }
 
 
  590    template<
class D, 
class DPtr>
 
  592      { 
return( lhs.get() == rhs.
get() ); }
 
 
  594    template<
class D, 
class DPtr>
 
  596      { 
return( lhs.
get() == 
nullptr ); }
 
 
  598    template<
class D, 
class DPtr>
 
  600      { 
return( 
nullptr == rhs.
get() ); }
 
 
  603    template<
class D, 
class DPtr>
 
  605      { 
return ! ( lhs == rhs ); }
 
 
  607    template<
class D, 
class DPtr>
 
  609      { 
return ! ( lhs == rhs ); }
 
 
  611    template<
class D, 
class DPtr>
 
  613      { 
return ! ( lhs == rhs ); }
 
 
  615    template<
class D, 
class DPtr>
 
  617      { 
return ! ( lhs == rhs ); }
 
 
  619    template<
class D, 
class DPtr>
 
  621      { 
return ! ( lhs == rhs ); }
 
 
  623    template<
class D, 
class DPtr>
 
  625      { 
return( lhs.
get() != 
nullptr ); }
 
 
  627    template<
class D, 
class DPtr>
 
  629      { 
return( 
nullptr != rhs.
get() ); }
 
 
  639#define DEFINE_PTR_TYPE(NAME) \ 
  641extern void intrusive_ptr_add_ref( const NAME * ) ZYPP_API;               \ 
  642extern void intrusive_ptr_release( const NAME * ) ZYPP_API;               \ 
  643typedef zypp::intrusive_ptr<NAME>       NAME##_Ptr;        \ 
  644typedef zypp::intrusive_ptr<const NAME> NAME##_constPtr; 
 
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
virtual UrlBase * clone() const
Returns pointer to a copy of the current object.
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
String related utilities and Regular expression matching.
Don't forgett to provide versions for PtrType and constPtrType, esp.
String related utilities and Regular expression matching.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
intrusive_ptr< T > make_intrusive(Args &&... __args)
shared_ptr custom deleter doing nothing.
void operator()(const void *const) const
bool operator==(const RWCOW_pointer< D, DPtr > &lhs, const RWCOW_pointer< D, DPtr > &rhs)
bool operator!=(const RWCOW_pointer< D, DPtr > &lhs, const typename DPtr::PtrType &rhs)
void swap(PtrType &rhs) noexcept
bool operator!=(const RWCOW_pointer< D, DPtr > &lhs, const RWCOW_pointer< D, DPtr > &rhs)
RWCOW_pointer & operator=(std::nullptr_t)
bool operator!=(const RWCOW_pointer< D, DPtr > &lhs, std::nullptr_t)
bool operator==(const RWCOW_pointer< D, DPtr > &lhs, const typename DPtr::PtrType &rhs)
bool operator==(std::nullptr_t, const RWCOW_pointer< D, DPtr > &rhs)
bool operator==(const RWCOW_pointer< D, DPtr > &lhs, std::nullptr_t)
const D & operator*() const
RWCOW_pointer & operator=(const RWCOW_pointer &)=default
RWCOW_pointer(RWCOW_pointer &&)=default
bool operator!=(const RWCOW_pointer< D, DPtr > &lhs, const typename DPtr::constPtrType &rhs)
const D * operator->() const
bool operator!=(std::nullptr_t, const RWCOW_pointer< D, DPtr > &rhs)
RWCOW_pointer(const RWCOW_pointer &)=default
bool operator!=(const typename DPtr::PtrType &lhs, const RWCOW_pointer< D, DPtr > &rhs)
bool operator!=(const typename DPtr::constPtrType &lhs, const RWCOW_pointer< D, DPtr > &rhs)
RWCOW_pointer & operator=(RWCOW_pointer &&)=default
RWCOW_pointer(std::nullptr_t)
constPtrType getPtr() const
bool operator==(const RWCOW_pointer< D, DPtr > &lhs, const typename DPtr::constPtrType &rhs)
RWCOW_pointer(PtrType dptr)
bool operator==(const typename DPtr::PtrType &lhs, const RWCOW_pointer< D, DPtr > &rhs)
bool operator==(const typename DPtr::constPtrType &lhs, const RWCOW_pointer< D, DPtr > &rhs)
RWCOW_pointer(typename PtrType::element_type *dptr)
void swap(RWCOW_pointer &rhs) noexcept
typename DTraits::PtrType PtrType
std::ostream & operator<<(std::ostream &str, const RWCOW_pointer< D, DPtr > &obj)
Stream output.
D * rwcowClone(const D *rhs)
Clone the underlying object.
void reset(typename PtrType::element_type *dptr)
typename DTraits::constPtrType constPtrType
typename rw_pointer::Shared< MediaVerifierBase >::constPtrType constPtrType
bool operator!=(const RW_pointer< D, DPtr > &lhs, std::nullptr_t)
bool operator!=(const RW_pointer< D, DPtr > &lhs, const typename DPtr::PtrType &rhs)
RW_pointer(std::nullptr_t)
bool operator==(const RW_pointer< D, DPtr > &lhs, std::nullptr_t)
RW_pointer(RW_pointer &&)=default
void swap(PtrType &rhs) noexcept
RW_pointer(typename PtrType::element_type *dptr)
std::ostream & operator<<(std::ostream &str, const RW_pointer< D, DPtr > &obj)
Stream output.
bool operator==(const RW_pointer< D, DPtr > &lhs, const typename DPtr::PtrType &rhs)
bool operator!=(const typename DPtr::PtrType &lhs, const RW_pointer< D, DPtr > &rhs)
bool operator!=(const typename DPtr::constPtrType &lhs, const RW_pointer< D, DPtr > &rhs)
const D * operator->() const
void reset(typename PtrType::element_type *dptr)
bool operator!=(const RW_pointer< D, DPtr > &lhs, const typename DPtr::constPtrType &rhs)
RW_pointer & operator=(const RW_pointer &)=default
constPtrType getPtr() const
bool operator==(const RW_pointer< D, DPtr > &lhs, const typename DPtr::constPtrType &rhs)
bool operator==(std::nullptr_t, const RW_pointer< D, DPtr > &rhs)
bool operator!=(std::nullptr_t, const RW_pointer< D, DPtr > &rhs)
const D & operator*() const
void swap(RW_pointer &rhs) noexcept
typename rw_pointer::Shared< MediaVerifierBase >::PtrType PtrType
RW_pointer(const RW_pointer &)=default
bool operator==(const typename DPtr::PtrType &lhs, const RW_pointer< D, DPtr > &rhs)
bool operator==(const typename DPtr::constPtrType &lhs, const RW_pointer< D, DPtr > &rhs)
RW_pointer & operator=(std::nullptr_t)
bool operator!=(const RW_pointer< D, DPtr > &lhs, const RW_pointer< D, DPtr > &rhs)
RW_pointer & operator=(RW_pointer &&)=default
bool operator==(const RW_pointer< D, DPtr > &lhs, const RW_pointer< D, DPtr > &rhs)
long use_count(const PtrType &ptr_r) const
intrusive_ptr< const D > constPtrType
intrusive_ptr< D > PtrType
long use_count(const constPtrType &ptr_r) const
Return number of references.
bool unique(const PtrType &ptr_r)
bool unique(const constPtrType &ptr_r)
Check whether pointer is not shared.
long use_count(const PtrType &ptr_r) const
bool unique(const constPtrType &ptr_r)
Check whether pointer is not shared.
scoped_ptr< const D > constPtrType
bool unique(const PtrType &ptr_r)
long use_count(const constPtrType &ptr_r) const
Return number of references.
long use_count(const PtrType &ptr_r) const
shared_ptr< const D > constPtrType
long use_count(const constPtrType &ptr_r) const
Return number of references.
bool unique(const constPtrType &ptr_r)
Check whether pointer is not shared.
bool unique(const PtrType &ptr_r)