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

akonadi

  • akonadi
agentfactory.h
1/*
2 This file is part of akonadiresources.
3
4 Copyright (c) 2006 Till Adam <adam@kde.org>
5 Copyright (c) 2007 Volker Krause <vkrause@kde.org>
6
7 This library is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Library General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
11
12 This library is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to the
19 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA.
21*/
22
23#ifndef AKONADI_AGENTFACTORY_H
24#define AKONADI_AGENTFACTORY_H
25
26#include "akonadi_export.h"
27#include "agentbase.h"
28
29#include <QtCore/QObject>
30#include <QtCore/QtPlugin>
31
32namespace Akonadi {
33
34class AgentFactoryBasePrivate;
35
43class AKONADI_EXPORT AgentFactoryBase : public QObject
44{
45 Q_OBJECT
46
47public:
55 explicit AgentFactoryBase(const char *catalogName, QObject *parent = 0);
56
57 virtual ~AgentFactoryBase();
58
59public Q_SLOTS:
63 virtual QObject *createInstance(const QString &identifier) const = 0;
64
65protected:
66 void createComponentData(const QString &identifier) const;
67
68private:
69 AgentFactoryBasePrivate *const d;
70};
71
79template <typename T>
80class AgentFactory : public AgentFactoryBase
81{
82public:
84 explicit AgentFactory(const char *catalogName, QObject *parent = 0)
85 : AgentFactoryBase(catalogName, parent)
86 {
87 }
88
89 QObject *createInstance(const QString &identifier) const
90 {
91 createComponentData(identifier);
92 T *instance = new T(identifier);
93
94 // check if T also inherits AgentBase::Observer and
95 // if it does, automatically register it on itself
96 Akonadi::AgentBase::Observer *observer = dynamic_cast<Akonadi::AgentBase::Observer *>(instance);
97 if (observer != 0) {
98 instance->registerObserver(observer);
99 }
100
101 return instance;
102 }
103};
104
105}
106
107#ifndef AKONADI_AGENT_FACTORY
115#define AKONADI_AGENT_FACTORY( agentClass, catalogName ) \
116class agentClass ## Factory : public Akonadi::AgentFactory< agentClass > \
117{ \
118 public: \
119 explicit agentClass ## Factory( QObject * parent = 0 ) : Akonadi::AgentFactory< agentClass >( # catalogName, parent ) {\
120 setObjectName(QLatin1String(# catalogName) );\
121 } \
122}; \
123Q_EXPORT_PLUGIN2( catalogName, agentClass ## Factory )
124
125#endif
126
127#endif
Akonadi::AgentBase::Observer
The interface for reacting on monitored or replayed changes.
Definition agentbase.h:187
Akonadi::AgentFactoryBase
A factory base class for in-process agents.
Definition agentfactory.h:44
Akonadi::AgentFactoryBase::createInstance
virtual QObject * createInstance(const QString &identifier) const =0
Creates a new agent instace with the given identifier.
Akonadi::AgentFactory
A factory for in-process agents.
Definition agentfactory.h:81
Akonadi::AgentFactory::AgentFactory
AgentFactory(const char *catalogName, QObject *parent=0)
reimplemented
Definition agentfactory.h:84
Akonadi::AgentFactory::createInstance
QObject * createInstance(const QString &identifier) const
Creates a new agent instace with the given identifier.
Definition agentfactory.h:89
Akonadi
FreeBusyManager::Singleton.
Definition actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 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