Commit 0bc00968 authored by Volker Krause's avatar Volker Krause
Browse files

Remove boost::shared_ptr support

This has long been superseded by std::shared_ptr and isn't used anywhere
anymore.
parent 127a3ee7
Pipeline #70082 passed with stage
in 10 minutes and 32 seconds
......@@ -55,7 +55,7 @@ class ItemPrivate;
* Technically the only restriction on payload objects is that they have to be copyable.
* For safety reasons, pointer payloads are forbidden as well though, as the
* ownership would not be clear. In this case, usage of a shared pointer is
* recommended (such as boost::shared_ptr, QSharedPointer or std::shared_ptr).
* recommended (such as QSharedPointer or std::shared_ptr).
*
* Using a shared pointer is also required in case the payload is a polymorphic
* type. For supported shared pointer types implicit casting is provided when possible.
......@@ -67,7 +67,7 @@ class ItemPrivate;
* Since KDE 4.6, Item supports multiple payload types per mime type,
* and will automatically convert between them using the serialiser
* plugins (which is slow). It also supports mixing shared pointer
* types, e.g. inserting a boost::shared_ptr<Foo> and extracting a
* types, e.g. inserting a std::shared_ptr<Foo> and extracting a
* QSharedPointer<Foo>. Since the two shared pointer types cannot
* share ownership of the same object, the payload class @c T needs to
* provide a @c clone() method with the usual signature, ie.
......@@ -87,7 +87,7 @@ class ItemPrivate;
* of the class), you want to restrict yourself to just one type and
* one shared pointer type. This mechanism was mainly introduced for
* backwards compatibility (e.g., putting in a
* boost::shared_ptr<KCal::Incidence> and extracting a
* std::shared_ptr<KCal::Incidence> and extracting a
* QSharedPointer<KCalCore::Incidence>), so it is not optimized for
* performance.
*
......@@ -557,9 +557,8 @@ public:
* fast (such as implicitly shared classes) is recommended.
* If the payload type is polymorphic and you intend to set and retrieve payload
* objects with mismatching but castable types, make sure to use a supported
* shared pointer implementation (currently boost::shared_ptr, QSharedPointer
* and std::shared_ptr and make sure there is a specialization of
* Akonadi::super_trait for your class.
* shared pointer implementation (currently QSharedPointer and std::shared_ptr)
* and make sure there is a specialization of Akonadi::super_trait for your class.
*/
template<typename T> void setPayload(const T &p);
/// @cond PRIVATE
......@@ -569,8 +568,8 @@ public:
/**
* Returns the payload object of this PIM item. This method will only succeed if either
* you requested the exact same payload type that was put in or the payload uses a
* supported shared pointer type (currently boost::shared_ptr, QSharedPointer and
* std::shared_ptr), and is castable to the requested type. For this to work there needs
* supported shared pointer type (currently QSharedPointer and std::shared_ptr),
* and is castable to the requested type. For this to work there needs
* to be a specialization of Akonadi::super_trait of the used classes.
*
* If a mismatching or non-castable payload type is requested, an Akonadi::PayloadException
......@@ -589,7 +588,7 @@ public:
/**
* Returns whether the item has a payload of type @c T.
* This method will only return @c true if either you requested the exact same payload type
* that was put in or the payload uses a supported shared pointer type (currently boost::shared_ptr,
* that was put in or the payload uses a supported shared pointer type (currently
* QSharedPointer and std::shared_ptr), and is castable to the requested type. For this to work there needs
* to be a specialization of Akonadi::super_trait of the used classes.
*
......
......@@ -14,8 +14,6 @@
#include <type_traits>
#include <typeinfo>
#include <boost/shared_ptr.hpp>
#include "exceptionbase.h"
/// @cond PRIVATE Doxygen 1.7.1 hangs processing this file. so skip it.
......@@ -26,14 +24,6 @@
* considered public API, and subject to change without notice
*/
// Forward-declare boost::shared_ptr so that we don't have to explicitly include
// it. Caller that tries to use it will already have it included anyway
namespace boost
{
template<typename T> class shared_ptr;
template<typename T, typename U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const &ptr) noexcept;
}
namespace Akonadi
{
namespace Internal
......@@ -78,17 +68,6 @@ template<typename T> struct shared_pointer_traits {
static const bool defined = false;
};
template<typename T> struct shared_pointer_traits<boost::shared_ptr<T>> {
static const bool defined = true;
using element_type = T;
template<typename S> struct make {
using type = boost::shared_ptr<S>;
};
using next_shared_ptr = QSharedPointer<T>;
};
template<typename T> struct shared_pointer_traits<QSharedPointer<T>> {
static const bool defined = true;
using element_type = T;
......@@ -108,7 +87,7 @@ template<typename T> struct shared_pointer_traits<std::shared_ptr<T>> {
using type = std::shared_ptr<S>;
};
using next_shared_ptr = boost::shared_ptr<T>;
using next_shared_ptr = QSharedPointer<T>;
};
template<typename T> struct is_shared_pointer {
......@@ -130,10 +109,6 @@ template<typename T> struct get_hierarchy_root_recurse<T, T> : identity<T> {
template<typename T> struct get_hierarchy_root : get_hierarchy_root_recurse<T, typename Akonadi::SuperClass<T>::Type> {
};
template<typename T> struct get_hierarchy_root<boost::shared_ptr<T>> {
using type = boost::shared_ptr<typename get_hierarchy_root<T>::type>;
};
template<typename T> struct get_hierarchy_root<QSharedPointer<T>> {
using type = QSharedPointer<typename get_hierarchy_root<T>::type>;
};
......@@ -195,66 +170,10 @@ template<typename T> struct PayloadTrait {
{
throw PayloadException("clone: you should never get here");
}
/// defines the type of shared pointer used (0: none, > 0: boost::shared_ptr, QSharedPointer, ...)
/// defines the type of shared pointer used (0: none, > 0: std::shared_ptr, QSharedPointer, ...)
static const unsigned int sharedPointerId = 0;
};
/**
@internal
Payload type trait specialization for boost::shared_ptr
for documentation of the various members, see above
*/
template<typename T> struct PayloadTrait<boost::shared_ptr<T>> {
using ElementType = T;
static int elementMetaTypeId()
{
return qMetaTypeId<T *>();
}
using SuperElementType = typename Akonadi::SuperClass<T>::Type;
using Type = boost::shared_ptr<ElementType>;
using SuperType = boost::shared_ptr<SuperElementType>;
static const bool isPolymorphic = !std::is_same<ElementType, SuperElementType>::value;
static inline bool isNull(const Type &p)
{
return p.get() == nullptr;
}
template<typename U> static inline Type castFrom(const boost::shared_ptr<U> &p)
{
const Type sp = boost::dynamic_pointer_cast<T, U>(p);
if (sp.get() != nullptr || p.get() == nullptr) {
return sp;
}
throw PayloadException("boost::dynamic_pointer_cast failed");
}
template<typename U> static inline bool canCastFrom(const boost::shared_ptr<U> &p)
{
const Type sp = boost::dynamic_pointer_cast<T, U>(p);
return sp.get() != nullptr || p.get() == nullptr;
}
template<typename U> static inline boost::shared_ptr<U> castTo(const Type &p)
{
const boost::shared_ptr<U> sp = boost::dynamic_pointer_cast<U>(p);
return sp;
}
static boost::shared_ptr<T> clone(const QSharedPointer<T> &t)
{
if (T *nt = clone_traits<T>::clone(t.data())) {
return boost::shared_ptr<T>(nt);
} else {
return boost::shared_ptr<T>();
}
}
static boost::shared_ptr<T> clone(const std::shared_ptr<T> &t)
{
if (T *nt = clone_traits<T>::clone(t.get())) {
return boost::shared_ptr<T>(nt);
} else {
return boost::shared_ptr<T>();
}
}
static const unsigned int sharedPointerId = 1;
};
/**
@internal
Payload type trait specialization for QSharedPointer
......@@ -292,14 +211,6 @@ template<typename T> struct PayloadTrait<QSharedPointer<T>> {
const QSharedPointer<U> sp = qSharedPointerDynamicCast<U, T>(p);
return sp;
}
static QSharedPointer<T> clone(const boost::shared_ptr<T> &t)
{
if (T *nt = clone_traits<T>::clone(t.get())) {
return QSharedPointer<T>(nt);
} else {
return QSharedPointer<T>();
}
}
static QSharedPointer<T> clone(const std::shared_ptr<T> &t)
{
if (T *nt = clone_traits<T>::clone(t.get())) {
......@@ -348,14 +259,6 @@ template<typename T> struct PayloadTrait<std::shared_ptr<T>> {
const std::shared_ptr<U> sp = std::dynamic_pointer_cast<U, T>(p);
return sp;
}
static std::shared_ptr<T> clone(const boost::shared_ptr<T> &t)
{
if (T *nt = clone_traits<T>::clone(t.get())) {
return std::shared_ptr<T>(nt);
} else {
return std::shared_ptr<T>();
}
}
static std::shared_ptr<T> clone(const QSharedPointer<T> &t)
{
if (T *nt = clone_traits<T>::clone(t.data())) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment