00001 #ifndef _O_HOLIDAY_PLUGIN_IF_H
00002 #define _O_HOLIDAY_PLUGIN_IF_H
00003 #include <opie2/odebug.h>
00004 #include <qpe/qcom.h>
00005
00006 #ifndef QT_NO_COMPONENT
00007
00008 #define IID_HOLIDAY_PLUGIN QUuid(0xc0a5f73f,0x975e,0x4492,0x92,0x85,0xaf,0x55,0x52,0x84,0xc4,0xab)
00009 #endif
00010
00011 namespace Opie {
00012 namespace Datebook {
00013
00014 class HolidayPlugin;
00015
00016 class HolidayPluginIf:public QUnknownInterface
00017 {
00018 public:
00019 HolidayPluginIf():QUnknownInterface(){}
00020 virtual ~HolidayPluginIf(){}
00021
00022 virtual HolidayPlugin*plugin()=0;
00023 };
00024
00025 template<class T> class HolidayPluginWrapper:public HolidayPluginIf
00026 {
00027 public:
00028 HolidayPluginWrapper():HolidayPluginIf(),_plugin(0){}
00029 virtual ~HolidayPluginWrapper(){if (_plugin) delete _plugin;}
00030
00031 QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface ) {
00032 *iface = 0;
00033 if (uuid == IID_HOLIDAY_PLUGIN || uuid == IID_QUnknown) {
00034 *iface = this;
00035 } else {
00036 return QS_FALSE;
00037 }
00038 if (*iface) (*iface)->addRef();
00039 return QS_OK;
00040 }
00041
00042
00043 Q_REFCOUNT
00044
00045 virtual T*plugin() {
00046 if (!_plugin) {_plugin = new T();}
00047 return _plugin;
00048 }
00049 protected:
00050 T*_plugin;
00051 };
00052
00053 #define EXPORT_HOLIDAY_PLUGIN( Plugin ) \
00054 Q_EXPORT_INTERFACE() { \
00055 Q_CREATE_INSTANCE( Opie::Datebook::HolidayPluginWrapper<Plugin> ) \
00056 }
00057 }
00058 }
00059 #endif
00060