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

KMIME Library

kmime_headerfactory_p.h

Go to the documentation of this file.
00001 /*
00002     kmime_header_factory.h
00003 
00004     KMime, the KDE Internet mail/usenet news message library.
00005     Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00033 #ifndef __KMIME_HEADERFACTORY_H__
00034 #define __KMIME_HEADERFACTORY_H__
00035 
00036 #include "kmime_export.h"
00037 
00038 #include <QtCore/QByteArray>
00039 
00040 namespace KMime {
00041 
00042 namespace Headers {
00043   class Base;
00044 }
00045 
00046 class HeaderMakerBase
00047 {
00048   public:
00049     virtual ~HeaderMakerBase() {}
00050     virtual Headers::Base *create() const = 0;
00051 };
00052 
00053 template <typename T>
00054 class HeaderMaker : public HeaderMakerBase
00055 {
00056   public:
00057     virtual Headers::Base *create() const
00058     {
00059       return new T;
00060     }
00061 };
00062 
00063 class HeaderFactoryPrivate;
00064 
00068 class HeaderFactory
00069 {
00070   public:
00071     static HeaderFactory* self();
00072 
00073     template<typename T> inline bool registerHeader()
00074     {
00075       T dummy;
00076       return registerHeaderMaker( QByteArray( dummy.type() ), new HeaderMaker<T>() );
00077     }
00078 
00079     Headers::Base *createHeader( const QByteArray &type );
00080 
00081   private:
00082     HeaderFactory( HeaderFactoryPrivate *dd );
00083     HeaderFactory( const HeaderFactory &other ); // undefined
00084     HeaderFactory& operator=( const HeaderFactory &other ); // undefined
00085     ~HeaderFactory();
00086 
00087     bool registerHeaderMaker( const QByteArray &type, HeaderMakerBase *maker );
00088 
00089     friend class HeaderFactoryPrivate;
00090     HeaderFactoryPrivate *const d;
00091 };
00092 
00093 } // namespace KMime
00094 
00095 #endif /* __KMIME_HEADERFACTORY_H__ */

KMIME Library

Skip menu "KMIME Library"
  • Main Page
  • 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
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.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