32#ifndef _QX_CONSTRUCT_PTR_H_
33#define _QX_CONSTRUCT_PTR_H_
46#include <QtCore/qsharedpointer.h>
48#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
49#include <QtCore/qscopedpointer.h>
67 typedef typename std::remove_pointer<T>::type
type_ptr;
71 static inline void get(T & t,
bool bReset =
false)
76 template <
bool isAbstract ,
int dummy>
78 {
static inline void get(T & t,
bool bReset) {
if (bReset) { t = NULL; }
else { t =
new type_ptr(); } } };
82 {
static inline void get(T & t,
bool bReset) { Q_UNUSED(t); Q_UNUSED(bReset); qDebug(
"[QxOrm] qx::trait::construct_ptr<T> : %s",
"cannot instantiate abstract class"); } };
86#ifdef _QX_ENABLE_BOOST
90{
static inline void get(boost::scoped_ptr<T> & t,
bool bReset =
false) {
if (bReset) { t.reset(); }
else { t.reset(
new T()); } } };
94{
static inline void get(boost::shared_ptr<T> & t,
bool bReset =
false) {
if (bReset) { t.reset(); }
else { t.reset(
new T()); } } };
98{
static inline void get(boost::intrusive_ptr<T> & t,
bool bReset =
false) {
if (bReset) { t.reset(); }
else { t.reset(
new T()); } } };
104{
static inline void get(QSharedPointer<T> & t,
bool bReset =
false) {
if (bReset) { t = QSharedPointer<T>(); }
else { t = QSharedPointer<T>(
new T()); } } };
106#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
109{
static inline void get(QScopedPointer<T> & t,
bool bReset =
false) {
if (bReset) { t = QScopedPointer<T>(); }
else { t = QScopedPointer<T>(
new T()); } } };
118{
static inline void get(std::unique_ptr<T> & t,
bool bReset =
false) {
if (bReset) { t.reset(); }
else { t.reset(
new T()); } } };
122{
static inline void get(std::shared_ptr<T> & t,
bool bReset =
false) {
if (bReset) { t.reset(); }
else { t = std::make_shared<T>(); } } };
qx::dao::ptr<T> : provide a classic smart-pointer (like boost::shared_ptr<T> or QSharedPointer<T>) wi...
qx::dao::ptr<T> : provide a classic smart-pointer (like boost::shared_ptr<T> or QSharedPointer<T>) wi...
Root namespace for all QxOrm library features.
static void get(T &t, bool bReset)
static void get(T &t, bool bReset)
static void get(QScopedPointer< T > &t, bool bReset=false)
static void get(QSharedPointer< T > &t, bool bReset=false)
static void get(boost::intrusive_ptr< T > &t, bool bReset=false)
static void get(boost::scoped_ptr< T > &t, bool bReset=false)
static void get(boost::shared_ptr< T > &t, bool bReset=false)
static void get(qx::dao::ptr< T > &t, bool bReset=false)
static void get(std::shared_ptr< T > &t, bool bReset=false)
static void get(std::unique_ptr< T > &t, bool bReset=false)
qx::trait::construct_ptr<T>::get(T & t, bool bReset = false) : instantiate (or reset) a new pointer,...
std::remove_pointer< T >::type type_ptr
static void get(T &t, bool bReset=false)