akonadi
entity_p.h
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 foreach ( Attribute* attr, other.mAttributes )
00061 mAttributes.insert( attr->type(), attr->clone() );
00062 mDeletedAttributes = other.mDeletedAttributes;
00063 if ( other.mParent )
00064 mParent = new Collection( *(other.mParent) );
00065 }
00066
00067 virtual void resetChangeLog()
00068 {
00069 mDeletedAttributes.clear();
00070 }
00071
00072 virtual EntityPrivate *clone() const = 0;
00073
00074 Entity::Id mId;
00075 QString mRemoteId;
00076 QHash<QByteArray, Attribute*> mAttributes;
00077 QSet<QByteArray> mDeletedAttributes;
00078 mutable Collection* mParent;
00079 };
00080
00081 }
00082
00090 template <>
00091 Q_INLINE_TEMPLATE Akonadi::EntityPrivate* QSharedDataPointer<Akonadi::EntityPrivate>::clone()
00092 {
00093 return d->clone();
00094 }
00095
00096 #endif