• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
entity.h
1 /*
2  Copyright (c) 2008 Tobias Koenig <tokoe@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #ifndef AKONADI_ENTITY_H
21 #define AKONADI_ENTITY_H
22 
23 #include "akonadi_export.h"
24 
25 namespace Akonadi {
26 class Entity;
27 }
28 
29 AKONADI_EXPORT uint qHash( const Akonadi::Entity& );
30 
31 #include <akonadi/attribute.h>
32 
33 #include <KDE/KDebug>
34 
35 #include <QtCore/QHash>
36 #include <QtCore/QSharedDataPointer>
37 
38 #define AKONADI_DECLARE_PRIVATE( Class ) \
39  Class##Private* d_func(); \
40  const Class##Private* d_func() const; \
41  friend class Class##Private;
42 
43 namespace Akonadi {
44 
45 class Collection;
46 class EntityPrivate;
47 
58 class AKONADI_EXPORT Entity
59 {
60  public:
64  typedef qint64 Id;
65 
69  void setId( Id identifier );
70 
74  Id id() const;
75 
79  void setRemoteId( const QString& id );
80 
84  QString remoteId() const;
85 
95  void setRemoteRevision( const QString& revision );
96 
103  QString remoteRevision() const;
104 
108  bool isValid() const;
109 
114  bool operator==( const Entity &other ) const;
115 
120  bool operator!=( const Entity &other ) const;
121 
125  Entity& operator=( const Entity &other );
126 
132  bool operator<( const Entity &other ) const;
133 
140  Collection parentCollection() const;
141 
148  Collection& parentCollection();
149 
159  void setParentCollection( const Collection &parent );
160 
171  void addAttribute( Attribute *attribute );
172 
176  void removeAttribute( const QByteArray &name );
177 
182  bool hasAttribute( const QByteArray &name ) const;
183 
187  Attribute::List attributes() const;
188 
192  void clearAttributes();
193 
197  Attribute* attribute( const QByteArray &name ) const;
198 
202  enum CreateOption {
203  AddIfMissing
204  };
205 
213  template <typename T> inline T* attribute( CreateOption option )
214  {
215  Q_UNUSED( option );
216 
217  const T dummy;
218  if ( hasAttribute( dummy.type() ) ) {
219  T* attr = dynamic_cast<T*>( attribute( dummy.type() ) );
220  if ( attr ) {
221  return attr;
222  }
223  kWarning( 5250 ) << "Found attribute of unknown type" << dummy.type()
224  << ". Did you forget to call AttributeFactory::registerAttribute()?";
225  }
226 
227  T* attr = new T();
228  addAttribute( attr );
229  return attr;
230  }
231 
235  template <typename T> inline T* attribute() const
236  {
237  const T dummy;
238  if ( hasAttribute( dummy.type() ) ) {
239  T* attr = dynamic_cast<T*>( attribute( dummy.type() ) );
240  if ( attr )
241  return attr;
242  kWarning( 5250 ) << "Found attribute of unknown type" << dummy.type()
243  << ". Did you forget to call AttributeFactory::registerAttribute()?";
244  }
245 
246  return 0;
247  }
248 
252  template <typename T> inline void removeAttribute()
253  {
254  const T dummy;
255  removeAttribute( dummy.type() );
256  }
257 
261  template <typename T> inline bool hasAttribute() const
262  {
263  const T dummy;
264  return hasAttribute( dummy.type() );
265  }
266 
267  protected:
271  Entity( const Entity &other );
272 
276  ~Entity();
277 
278  //@cond PRIVATE
279  Entity( EntityPrivate *dd );
280  QSharedDataPointer<EntityPrivate> d_ptr;
281  //@endcond
282 
283  AKONADI_DECLARE_PRIVATE( Entity )
284 };
285 
286 }
287 
288 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:35 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

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

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal