• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi

entity.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 AKONADI_ENTITY_H
00021 #define AKONADI_ENTITY_H
00022 
00023 #include "akonadi_export.h"
00024 
00025 namespace Akonadi {
00026 class Entity;
00027 }
00028 
00029 AKONADI_EXPORT uint qHash( const Akonadi::Entity& );
00030 
00031 #include <akonadi/attribute.h>
00032 
00033 #include <QtCore/QHash>
00034 #include <QtCore/QSharedDataPointer>
00035 
00036 #define AKONADI_DECLARE_PRIVATE( Class ) \
00037     Class##Private* d_func(); \
00038     const Class##Private* d_func() const; \
00039     friend class Class##Private;
00040 
00041 namespace Akonadi {
00042 
00043 class EntityPrivate;
00044 
00055 class AKONADI_EXPORT Entity
00056 {
00057   public:
00061     typedef qint64 Id;
00062 
00066     ~Entity();
00067 
00071     void setId( Id identifier );
00072 
00076     Id id() const;
00077 
00081     void setRemoteId( const QString& id );
00082 
00086     QString remoteId() const;
00087 
00091     bool isValid() const;
00092 
00097     bool operator==( const Entity &other ) const;
00098 
00103     bool operator!=( const Entity &other ) const;
00104 
00108     Entity& operator=( const Entity &other );
00109 
00120     void addAttribute( Attribute *attribute );
00121 
00125     void removeAttribute( const QByteArray &name );
00126 
00131     bool hasAttribute( const QByteArray &name ) const;
00132 
00136     Attribute::List attributes() const;
00137 
00141     void clearAttributes();
00142 
00146     Attribute* attribute( const QByteArray &name ) const;
00147 
00151     enum CreateOption
00152     {
00153       AddIfMissing    
00154     };
00155 
00163     template <typename T> inline T* attribute( CreateOption option )
00164     {
00165       Q_UNUSED( option );
00166 
00167       const T dummy;
00168       if ( hasAttribute( dummy.type() ) )
00169         return static_cast<T*>( attribute( dummy.type() ) );
00170 
00171       T* attr = new T();
00172       addAttribute( attr );
00173       return attr;
00174     }
00175 
00179     template <typename T> inline T* attribute() const
00180     {
00181       const T dummy;
00182       if ( hasAttribute( dummy.type() ) )
00183         return static_cast<T*>( attribute( dummy.type() ) );
00184       return 0;
00185     }
00186 
00190     template <typename T> inline void removeAttribute()
00191     {
00192       const T dummy;
00193       removeAttribute( dummy.type() );
00194     }
00195 
00199     template <typename T> inline bool hasAttribute() const
00200     {
00201       const T dummy;
00202       return hasAttribute( dummy.type() );
00203     }
00204 
00205   protected:
00209     Entity( const Entity &other );
00210 
00211     //@cond PRIVATE
00212     Entity( EntityPrivate *dd );
00213     QSharedDataPointer<EntityPrivate> d_ptr;
00214     //@endcond
00215 
00216     AKONADI_DECLARE_PRIVATE( Entity )
00217 };
00218 
00219 }
00220 
00221 #endif

akonadi

Skip menu "akonadi"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal