kradioapp.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           kradioapp.h  -  description
00003                              -------------------
00004     begin                : Sa Feb  9 2002
00005     copyright            : (C) 2002 by Klas Kalass / Martin Witte / Frank Schwanz
00006     email                : klas.kalass@gmx.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef KRADIO_KRADIOAPP_H
00019 #define KRADIO_KRADIOAPP_H
00020 
00021 #ifdef HAVE_CONFIG_H
00022 #include <config.h>
00023 #endif
00024 
00025 #include <qdict.h>
00026 
00027 #include <kapplication.h>
00028 #include <kaboutapplication.h>
00029 #include "pluginmanager.h"
00030 #include "plugins.h"
00031 
00032 class KLibrary;
00033 
00034 class KRadioAbout : public PluginBase
00035 {
00036 public:
00037     KRadioAbout(const QString &name) : PluginBase(name, "KRadio Application") {}
00038 
00039     virtual QString pluginClassName() const { return "KRadioAbout"; }
00040 
00041     virtual ConfigPageInfo createConfigurationPage () { return ConfigPageInfo(); }
00042     virtual AboutPageInfo  createAboutPage ();
00043 
00044     virtual void   saveState    (KConfig *) const {}
00045     virtual void   restoreState (KConfig *)       {}
00046 };
00047 
00048 
00049 
00050 
00051 typedef  PluginBase     *(*t_kradio_plugin_init_func)(const QString & cls, const QString &obj);
00052 typedef  void            (*t_kradio_plugin_info_func)(QMap<QString, QString> &);
00053 typedef  void            (*t_kradio_plugin_libload_func)();
00054 typedef  void            (*t_kradio_plugin_libunload_func)();
00055 
00056 
00057 struct PluginLibraryInfo {
00058     KLibrary                      *library;
00059     QMap<QString,QString>          plugins;
00060     t_kradio_plugin_init_func      init_func;
00061     t_kradio_plugin_info_func      info_func;
00062     t_kradio_plugin_libload_func   libload_func;
00063     t_kradio_plugin_libunload_func libunload_func;
00064 
00065     PluginLibraryInfo() : library(NULL), init_func(NULL), info_func(NULL), libload_func(NULL), libunload_func(NULL) {}
00066     PluginLibraryInfo(const QString &libname);
00067     bool valid() { return init_func && info_func && library && libload_func && libunload_func; }
00068 };
00069 
00070 
00071 struct PluginClassInfo {
00072     QString                    class_name;
00073     QString                    description;
00074     t_kradio_plugin_init_func  create_function;
00075 
00076     PluginClassInfo() : create_function(NULL) {}
00077     PluginClassInfo(const QString &_name, const QString &descr, t_kradio_plugin_init_func init_func)
00078         : class_name(_name), description(descr), create_function(init_func) {}
00079     PluginBase *CreateInstance(const QString &obj_name) { return create_function ? create_function(class_name, obj_name) : NULL; }
00080 };
00081 
00082 
00083 class KRadioApp : public KApplication
00084 {
00085 Q_OBJECT
00086 public:
00087     KRadioApp();
00088     virtual ~KRadioApp();
00089 
00090     virtual void             saveState    (KConfig *c);
00091     virtual void             restoreState (KConfig *c);
00092 
00093     virtual PluginManager   *createNewInstance(const QString &name);
00094 
00095     virtual KLibrary   *LoadLibrary (const QString &library);
00096     virtual void        UnloadLibrary (const QString &library);
00097     virtual PluginBase *CreatePlugin (PluginManager *manager, const QString &name, const QString &object_name);
00098 
00099     virtual const QMap<QString, PluginLibraryInfo> &getPluginLibraries() const { return m_PluginLibraries; }
00100     virtual const QMap<QString, PluginClassInfo>   &getPluginClasses()   const { return m_PluginInfos; }
00101 
00102     virtual void  startPlugins();
00103 
00104 protected slots:
00105 
00106     virtual void  saveState();
00107     virtual void  slotAboutToQuit();
00108 
00109 protected:
00110 
00111     QDict<PluginManager>        m_Instances;
00112 
00113     QMap<QString, PluginLibraryInfo>  m_PluginLibraries;
00114     QMap<QString, PluginClassInfo>    m_PluginInfos;
00115 
00116     bool                              m_quitting;
00117 };
00118 
00119 
00120 #endif

Generated on Fri Jan 28 16:42:13 2011 for kradio by  doxygen 1.4.7