13#ifndef ZYPP_BASE_PTRTYPES_H
14#define ZYPP_BASE_PTRTYPES_H
19#include <boost/scoped_ptr.hpp>
20#include <boost/shared_ptr.hpp>
21#include <boost/weak_ptr.hpp>
22#include <boost/intrusive_ptr.hpp>
31 std::string
form(
const char * format, ... ) __attribute__ ((format (printf, 1, 2)));
89 using boost::scoped_ptr;
92 using boost::shared_ptr;
95 using boost::weak_ptr;
98 using boost::intrusive_ptr;
100 template<
typename T,
typename... Args>
107 using boost::static_pointer_cast;
109 using boost::const_pointer_cast;
111 using boost::dynamic_pointer_cast;
136 return str << std::string(
"NULL");
144 return str << std::string(
"NULL");
152 return dumpOn(
str, *obj );
153 return str << std::string(
"NULL");
158 {
return str << obj; }
166 return str << std::string(
"NULL");
174 return str << std::string(
"NULL");
193 namespace rw_pointer {
207 {
return ptr_r.use_count(); }
209 {
return ptr_r.use_count(); }
219 {
return !
ptr_r || (
ptr_r->refCount() <= 1); }
221 {
return !
ptr_r || (
ptr_r->refCount() <= 1); }
241 {
return ptr_r ? 1 : 0; }
243 {
return ptr_r ? 1 : 0; }
290 template<
class D,
class DTraits = rw_po
inter::Shared<D> >
316 {
reset();
return *
this; }
331 {
return _dptr.get() !=
nullptr; }
337 {
return _dptr.operator->(); }
340 {
return _dptr.get(); }
346 {
return _dptr.operator->(); }
349 {
return _dptr.get(); }
377 template<
class D,
class DPtr>
382 return str << std::string(
"NULL");
386 template<
class D,
class DPtr>
388 {
return( lhs.get() == rhs.get() ); }
390 template<
class D,
class DPtr>
392 {
return( lhs.get() == rhs.get() ); }
394 template<
class D,
class DPtr>
396 {
return( lhs.get() == rhs.get() ); }
398 template<
class D,
class DPtr>
400 {
return( lhs.get() == rhs.get() ); }
402 template<
class D,
class DPtr>
404 {
return( lhs.get() == rhs.get() ); }
406 template<
class D,
class DPtr>
408 {
return( lhs.get() ==
nullptr ); }
410 template<
class D,
class DPtr>
412 {
return(
nullptr == rhs.get() ); }
416 template<
class D,
class DPtr>
418 {
return ! ( lhs == rhs ); }
420 template<
class D,
class DPtr>
422 {
return ! ( lhs == rhs ); }
424 template<
class D,
class DPtr>
426 {
return ! ( lhs == rhs ); }
428 template<
class D,
class DPtr>
430 {
return ! ( lhs == rhs ); }
432 template<
class D,
class DPtr>
434 {
return ! ( lhs == rhs ); }
436 template<
class D,
class DPtr>
438 {
return( lhs.get() !=
nullptr ); }
440 template<
class D,
class DPtr>
442 {
return(
nullptr != rhs.get() ); }
453 {
return rhs->clone(); }
466 template<
class D,
class DTraits = rw_po
inter::Shared<D> >
491 {
reset();
return *
this; }
510 {
return _dptr.get() !=
nullptr; }
516 {
return _dptr.operator->(); }
519 {
return _dptr.get(); }
564 template<
class D,
class DPtr>
569 return str << std::string(
"NULL");
573 template<
class D,
class DPtr>
575 {
return( lhs.get() == rhs.get() ); }
577 template<
class D,
class DPtr>
579 {
return( lhs.get() == rhs.get() ); }
581 template<
class D,
class DPtr>
583 {
return( lhs.get() == rhs.get() ); }
585 template<
class D,
class DPtr>
587 {
return( lhs.get() == rhs.get() ); }
589 template<
class D,
class DPtr>
591 {
return( lhs.get() == rhs.get() ); }
593 template<
class D,
class DPtr>
595 {
return( lhs.get() ==
nullptr ); }
597 template<
class D,
class DPtr>
599 {
return(
nullptr == rhs.get() ); }
602 template<
class D,
class DPtr>
604 {
return ! ( lhs == rhs ); }
606 template<
class D,
class DPtr>
608 {
return ! ( lhs == rhs ); }
610 template<
class D,
class DPtr>
612 {
return ! ( lhs == rhs ); }
614 template<
class D,
class DPtr>
616 {
return ! ( lhs == rhs ); }
618 template<
class D,
class DPtr>
620 {
return ! ( lhs == rhs ); }
622 template<
class D,
class DPtr>
624 {
return( lhs.get() !=
nullptr ); }
626 template<
class D,
class DPtr>
628 {
return(
nullptr != rhs.get() ); }
638#define DEFINE_PTR_TYPE(NAME) \
640extern void intrusive_ptr_add_ref( const NAME * ); \
641extern void intrusive_ptr_release( const NAME * ); \
642typedef zypp::intrusive_ptr<NAME> NAME##_Ptr; \
643typedef 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)