46#include <QtCore/qobject.h>
54#define QX_STR_CANNOT_INSTANTIATE_ABSTRACT_CLASS "[QxOrm] qx::QxFactory<T> ---> cannot instantiate abstract class '%s'"
56#if _QX_AUTO_REGISTER_REPOSITORY
57#define QX_AUTO_REGISTER_REPOSITORY(className, sKey) qx::register_repository< className >(sKey);
59#define QX_AUTO_REGISTER_REPOSITORY(className, sKey)
65template <
class T>
class QxClass;
67#ifdef _QX_ENABLE_QT_NETWORK
74#if _QX_AUTO_REGISTER_REPOSITORY
92#ifdef _QX_ENABLE_QT_NETWORK
100 {
QxClass<T>::getSingleton();
return qxCreateInstance<std::is_abstract<T>::value, std::is_base_of<qx::IxPersistable, T>::value,
false,
false, std::is_base_of<QObject, T>::value, 0>
::create(bRawPointer); }
103 {
QxClass<T>::getSingleton();
return qxCreateInstance<std::is_abstract<T>::value, std::is_base_of<qx::IxPersistable, T>::value,
false,
false, std::is_base_of<QObject, T>::value, 0>::createNudePtr(); }
108 {
return typeid(T); }
113 template <
bool bIsAbstract ,
bool bIsIxPersistable ,
bool bIsIxService ,
bool bIsIxParameter ,
bool bIsQObject ,
int dummy>
116 static inline qx::any create(
bool bRawPointer) {
if (bRawPointer) { T * p =
new T();
return qx::any(p); }; std::shared_ptr<T> ptr = std::make_shared<T>();
return qx::any(ptr); }
117 static inline void *
createNudePtr() {
return static_cast<void *
>(
new T()); }
120 template <
bool bIsIxPersistable,
bool bIsIxService,
bool bIsIxParameter,
bool bIsQObject,
int dummy>
121 struct qxCreateInstance<true, bIsIxPersistable, bIsIxService, bIsIxParameter, bIsQObject, dummy>
127 template <
bool bIsQObject,
int dummy>
130 static inline qx::any create(
bool bRawPointer) {
if (bRawPointer) { T * p =
new T();
return qx::any(p); }; std::shared_ptr<T> ptr = std::make_shared<T>();
return qx::any(ptr); }
134#ifdef _QX_ENABLE_QT_NETWORK
135 template <
bool bIsQObject,
int dummy>
138 static inline qx::any create(
bool bRawPointer) {
if (bRawPointer) { T * p =
new T();
return qx::any(p); }; std::shared_ptr<T> ptr = std::make_shared<T>();
return qx::any(ptr); }
142 template <
bool bIsQObject,
int dummy>
145 static inline qx::any create(
bool bRawPointer) {
if (bRawPointer) { T * p =
new T();
return qx::any(p); }; std::shared_ptr<T> ptr = std::make_shared<T>();
return qx::any(ptr); }
153 static inline qx::any create(
bool bRawPointer) {
if (bRawPointer) { T * p =
new T();
return qx::any(p); }; std::shared_ptr<T> ptr = std::make_shared<T>();
return qx::any(ptr); }
154 static inline void *
createNudePtr() {
return static_cast<QObject *
>(
new T()); }
161#include "../../inl/QxFactory/QxFactory.inl"
Common interface for all classes that can be created dynamically using the class name.
#define QX_AUTO_REGISTER_REPOSITORY(className, sKey)
#define QX_STR_CANNOT_INSTANTIATE_ABSTRACT_CLASS
qx::IxFactory : common interface for all classes that can be created dynamically using the class name
qx::IxPersistable : common interface (abstract class) for persistents classes using QX_PERSISTABLE_HP...
qx::QxFactory<T> : concrete factory class to create object of type T dynamically using the class name
QxFactory(const QString &sKey)
virtual qx::any createObject(bool bRawPointer=false) const
virtual const std::type_info & typeInfo() const
virtual void * createObjectNudePtr() const
static T * getSingleton()
qx::service::IxParameter : common interface for all parameters transfered by QxService module of QxOr...
qx::service::IxService : common interface for all services defined with QxService module of QxOrm lib...
qx::trait::get_base_class<T>::type : retrieve base class of type T registered into QxOrm context and ...
qx::trait::get_class_name<T>::get() : return class name of type T under const char * format,...
qx::trait::get_primary_key<T>::type : return primary key type of T, by default primary key is long ty...
qx::any create(const QString &sKey, bool bRawPointer=false)
Return a smart-pointer new instance of object (std::shared_ptr<T>) associated by key sKey using qx::a...
Root namespace for all QxOrm library features.
void register_repository(const QString &sKey)
static void * createNudePtr()
static qx::any create(bool bRawPointer)
static qx::any create(bool bRawPointer)
static void * createNudePtr()
static qx::any create(bool bRawPointer)
static void * createNudePtr()
static void * createNudePtr()
static qx::any create(bool bRawPointer)
static qx::any create(bool bRawPointer)
static void * createNudePtr()
static qx::any create(bool bRawPointer)
static void * createNudePtr()
qx::trait::get_class_name<T>::get() : return class name of type T under const char * format,...