00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ENTITY_P_H
00021 #define ENTITY_P_H
00022
00023 #include "entity.h"
00024 #include "collection.h"
00025
00026 #include <QtCore/QSet>
00027 #include <QtCore/QSharedData>
00028 #include <QtCore/QString>
00029
00030 #define AKONADI_DEFINE_PRIVATE( Class ) \
00031 Class##Private* Class ::d_func() { return reinterpret_cast<Class##Private *>( d_ptr.data() ); } \
00032 const Class##Private* Class ::d_func() const { return reinterpret_cast<const Class##Private *>( d_ptr.data() ); }
00033
00034 namespace Akonadi {
00035
00039 class EntityPrivate : public QSharedData
00040 {
00041 public:
00042 EntityPrivate( Entity::Id id = -1 )
00043 : mId( id ),
00044 mParent( 0 )
00045 {
00046 }
00047
00048 virtual ~EntityPrivate()
00049 {
00050 qDeleteAll( mAttributes );
00051 delete mParent;
00052 }
00053
00054 EntityPrivate( const EntityPrivate &other )
00055 : QSharedData( other ),
00056 mParent( 0 )
00057 {
00058 mId = other.mId;
00059 mRemoteId = other.mRemoteId;
00060 mRemoteRevision = other.mRemoteRevision;
00061 foreach ( Attribute* attr, other.mAttributes )
00062 mAttributes.insert( attr->type(), attr->clone() );
00063 mDeletedAttributes = other.mDeletedAttributes;
00064 if ( other.mParent )
00065 mParent = new Collection( *(other.mParent) );
00066 }
00067
00068 virtual void resetChangeLog()
00069 {
00070 mDeletedAttributes.clear();
00071 }
00072
00073 virtual EntityPrivate *clone() const = 0;
00074
00075 Entity::Id mId;
00076 QString mRemoteId;
00077 QString mRemoteRevision;
00078 QHash<QByteArray, Attribute*> mAttributes;
00079 QSet<QByteArray> mDeletedAttributes;
00080 mutable Collection* mParent;
00081 };
00082
00083 }
00084
00092 template <>
00093 Q_INLINE_TEMPLATE Akonadi::EntityPrivate* QSharedDataPointer<Akonadi::EntityPrivate>::clone()
00094 {
00095 return d->clone();
00096 }
00097
00098 #endif