3 // (c) Konrad Rosenbaum, 2010-2011
4 // Copying and distribution of this file, with or without modification,
5 // are permitted in any medium without royalty provided the copyright
6 // notice and this notice are preserved. This file is offered as-is,
7 // without any warranty.
12 #ifndef DPTR_CLASS_0_1_H
13 #define DPTR_CLASS_0_1_H
17 namespace Chester_0_1{
20 /** \brief Base class of non-shared d-pointers.
22 Use in conjunction with DECLARE_DPTR and DEFINE_DPTR */
26 ///instantiates a non-shared d-pointer
28 ///deletes a non-shared d-pointer
35 using namespace Chester_0_1;
43 /** \brief Creates definitions for methods of the non-shared d-pointer wrapper.
45 This variant is not shared between instances of the containing class, but it is able to copy its content (using the contents copy constructor and assignment operator). You cannot use this variant if any of the content classes have inaccessable copy constructors or assignment operators (like Qt's QObject and its subclasses).
47 To be used in implementation where the actual d-pointer class is implemented.
49 \param Class the base class within which the d-pointer was declared*/
50 #define DEFINE_DPTR(Class) \
51 Class::DPrivate::DPrivate(){d=new Class::Private;}\
52 Class::DPrivate::DPrivate(const Class::DPrivate&dp){d=new Class::Private(*(dp.d));}\
53 Class::DPrivate::~DPrivate(){delete d;}\
54 Class::DPrivate Class::DPrivate::clone()const{DPrivate r;*(r.d)=*d;return r;}\
55 Class::DPrivate& Class::DPrivate::operator=(const Class::DPrivate&dp)\
56 {if(d!=dp.d)*d=*(dp.d);return *this;}