Go to the source code of this file.
Macros | |
#define | DPTR_CLASS_NAME(Class) Class::Private |
Expands to the fully qualified name of the d-pointer class. More... | |
#define | DPTR_NAME Private |
Expands to the local name of d-pointer classes (Private). More... | |
#define | DPTR_WRAPPER_NAME DPrivate |
Expands to the local name of the d-pointer wrapper class (DPrivate). More... | |
#define | DECLARE_DPTR(dp) DECLARE_DPTRX(dp,) |
Declares a smart non-shared d-pointer, to be used inside class declaration. More... | |
#define | DECLARE_DPTRX(dp, export_spec) |
#define | DECLARE_SHARED_DPTR(dp) DECLARE_SHARED_DPTRX(dp,) |
Declares a smart shared d-pointer, to be used inside class declaration. More... | |
#define | DECLARE_SHARED_DPTRX(dp, export_spec) |
#define | DECLARE_NONCOPY_DPTR(dp) DECLARE_NONCOPY_DPTRX(dp,) |
Declares a smart non-shared and non-copyable d-pointer, to be used inside class declaration. More... | |
#define | DECLARE_NONCOPY_DPTRX(dp, export_spec) |
#define DECLARE_DPTR | ( | dp | ) | DECLARE_DPTRX(dp,) |
Declares a smart non-shared d-pointer, to be used inside class declaration.
It also declares the internal nested classes DPrivate and Private - Private is the actual d-pointer class, while DPrivate is a wrapper that automatically allocates, copies and deallocates the d-pointer.
The wrapper DPointer class contains these methods:
You can use DEFINE_DPTR to define the necessary methods for a non-shared d-pointer. It is recommended (but not necessary) that non-shared d-pointer classes (Private) are derived from DPtr.
The d-pointer class Private is only forward declared, you have to fully declare and implement it in the code where you are using it, i.e. where you are implementing the containing class.
Use the DECLARE_DPTRX version if your surrounding class is part of a library's exported API.
dp | name of the d-pointer |
export_spec | use Q_DECL_EXPORT or Q_DECL_IMPORT to signal public API export or import |
#define DECLARE_DPTRX | ( | dp, | |
export_spec | |||
) |
#define DECLARE_NONCOPY_DPTR | ( | dp | ) | DECLARE_NONCOPY_DPTRX(dp,) |
Declares a smart non-shared and non-copyable d-pointer, to be used inside class declaration.
It also declares the internal nested classes DPrivate and Private - Private is the actual d-pointer class, while DPrivate is a wrapper that automatically allocates, and deallocates the d-pointer. These are usable for content classes that do not allow copying (e.g. Qt's QObject and its subclasses).
The wrapper DPointer class contains these methods:
You can use DEFINE_NONCOPY_DPTR to define the necessary methods for a non-shared, non-copy d-pointer. It is recommended that d-pointer classes (Private) are derived from NonCopyDPtr.
The d-pointer class Private is only forward declared, you have to fully declare and implement it in the code where you are using it, i.e. where you are implementing the containing class.
Use the DECLARE_NONCOPY_DPTRX version if your surrounding class is part of a library's exported API.
dp | name of the d-pointer |
export_spec | use Q_DECL_EXPORT or Q_DECL_IMPORT to signal public API export or import |
#define DECLARE_NONCOPY_DPTRX | ( | dp, | |
export_spec | |||
) |
#define DECLARE_SHARED_DPTR | ( | dp | ) | DECLARE_SHARED_DPTRX(dp,) |
Declares a smart shared d-pointer, to be used inside class declaration.
It also declares the internal nested classes DPrivate and Private - Private is the actual d-pointer class, while DPrivate is a wrapper that automatically allocates, copies and deallocates the d-pointer.
The wrapper DPointer class contains these methods:
You can use DEFINE_DPTR to define the necessary methods for a non-shared d-pointer or DEFINE_SHARED_DPTR if you want to share d-pointer data between instances of the containing class. It is recommended that non-shared d-pointer classes (Private) are derived from DPtr and the shared variants be derived from SharedDPtr.
The d-pointer class Private is only forward declared, you have to fully declare and implement it in the code where you are using it, i.e. where you are implementing the containing class.
Warning: shared d-pointers are not thread safe and they are only re-entrant if instances sharing the same d-pointer are only located in one thread, while instances with different d-pointers may be spread over different threads.
Use the DECLARE_SHARED_DPTRX version if your surrounding class is part of a library's exported API.
dp | name of the d-pointer |
export_spec | use Q_DECL_EXPORT or Q_DECL_IMPORT to signal public API export or import |
#define DECLARE_SHARED_DPTRX | ( | dp, | |
export_spec | |||
) |
#define DPTR_CLASS_NAME | ( | Class | ) | Class::Private |
Expands to the fully qualified name of the d-pointer class.
Class | the fully qualified name of the class the d-pointer was declared in. |
#define DPTR_NAME Private |
Expands to the local name of d-pointer classes (Private).
#define DPTR_WRAPPER_NAME DPrivate |
Expands to the local name of the d-pointer wrapper class (DPrivate).