• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • viewer
pluginloader.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  This file is part of libkdepim.
3 
4  Copyright (c) 2002,2004 Marc Mutz <mutz@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef PLUGINLOADER_H
23 #define PLUGINLOADER_H
24 
25 #include "pluginloaderbase.h"
26 #include <KLibrary>
27 
77 template< typename T, typename T_config >
78 class PluginLoader : public PluginLoaderBase {
79 protected:
80  PluginLoader() : PluginLoaderBase() {}
81 
82 private:
83  static PluginLoader<T,T_config> * mSelf;
84 
85 public:
86  virtual ~PluginLoader() { mSelf = 0; }
87 
89  static PluginLoader<T,T_config> * instance() {
90  if ( !mSelf ) {
91  mSelf = new PluginLoader<T,T_config>();
92  mSelf->scan();
93  }
94  return mSelf;
95  }
96 
100  virtual void scan() {
101  doScan( T_config::path );
102  }
103 
107  virtual T * createForName( const QString & type ) const {
108  KLibrary::void_function_ptr main_func = mainFunc( type, T_config::mainfunc );
109  if ( !main_func ) return 0;
110 
111  // cast to a pointer to a function returning T*, call it and
112  // return the result; don't you love C? ;-)
113  return ((T* (*)())( main_func ))();
114  }
115 };
116 
117 template< typename T, typename T_config >
118 PluginLoader<T,T_config> * PluginLoader<T,T_config>::mSelf = 0;
119 
120 #define DEFINE_PLUGIN_LOADER( pl, t, mf, p ) \
121  namespace { /* don't pollute namespaces */ \
122  struct KDE_EXPORT pl##Config { \
123  static const char * const mainfunc; \
124  static const char * const path; \
125  }; \
126  const char * const pl##Config::mainfunc = mf; \
127  const char * const pl##Config::path = p; \
128  } \
129  typedef PluginLoader< t, pl##Config > pl; \
130 
131 
132 #endif // PLUGINLOADER_H
PluginLoader::createForName
virtual T * createForName(const QString &type) const
Returns a pointer to a plugin object (of type T) or a null pointer if the type wasn't found...
Definition: pluginloader.h:107
PluginLoader::~PluginLoader
virtual ~PluginLoader()
Definition: pluginloader.h:86
PluginLoader::scan
virtual void scan()
Rescans the plugin directory to find any newly installed plugins.
Definition: pluginloader.h:100
pluginloaderbase.h
PluginLoader
A generic plugin loader for when KPart::Plugin is overkill.
Definition: pluginloader.h:78
PluginLoaderBase::doScan
void doScan(const char *path)
Rescans the plugin directory to find any newly installed plugins.
Definition: pluginloaderbase.cpp:52
type
const char * type
Definition: bodypartformatter.cpp:192
PluginLoaderBase
Definition: pluginloaderbase.h:45
PluginLoader::PluginLoader
PluginLoader()
Definition: pluginloader.h:80
PluginLoaderBase::mainFunc
KLibrary::void_function_ptr mainFunc(const QString &type, const char *main_func) const
Returns a pointer to symbol main_func in the library that implements the plugin of type type...
Definition: pluginloaderbase.cpp:97
PluginLoader::instance
static PluginLoader< T, T_config > * instance()
Returns the single instance of this loader.
Definition: pluginloader.h:89
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



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