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;
137 return str << std::string(
"NULL");
145 return str << std::string(
"NULL");
153 return dumpOn(
str, *obj );
154 return str << std::string(
"NULL");
159 {
return str << obj; }
167 return str << std::string(
"NULL");
175 return str << std::string(
"NULL");
194 namespace rw_pointer {
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); }
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; }
332 {
return _dptr.get() !=
nullptr; }
338 {
return _dptr.operator->(); }
341 {
return _dptr.get(); }
347 {
return _dptr.operator->(); }
350 {
return _dptr.get(); }
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; }
511 {
return _dptr.get() !=
nullptr; }
517 {
return _dptr.operator->(); }
520 {
return _dptr.get(); }
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)
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void swap(AutoDispose &rhs) noexcept
Exchange the contents of two AutoDispose objects.
bool unique() const
Returns true if this is the only AutoDispose instance managing the current data object.
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
RW_pointer supporting 'copy on write' functionality.
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
Wrapper for const correct access via Smart pointer types.
typename DTraits::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 DTraits::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
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.
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
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)