akonadi
entity_p.h
00001 /* 00002 Copyright (c) 2008 Tobias Koenig <tokoe@kde.org> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 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
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:09:22 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:09:22 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.