Trade equipment common library.  1.0.0
teplugin.h
1 /****************************************************************************
2 ** $Id: teplugin.h,v 1.3 2006/04/29 10:15:47 red75 Exp $
3 **
4 ** Extension plugin object header file of
5 ** Ananas application library
6 **
7 ** Created : 20031201
8 **
9 ** Copyright (C) 2003-2004 Leader InfoTech. All rights reserved.
10 ** Copyright (C) 2003-2005 Grigory Panov, Yoshkar-Ola.
11 **
12 ** This file is part of the Designer application of the Ananas
13 ** automation accounting system.
14 **
15 ** This file may be distributed and/or modified under the terms of the
16 ** GNU General Public License version 2 as published by the Free Software
17 ** Foundation and appearing in the file LICENSE.GPL included in the
18 ** packaging of this file.
19 **
20 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 **
23 ** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru
24 ** See http://www.leaderit.ru/gpl/ for GPL licensing information.
25 **
26 ** Contact org@leaderit.ru if any conditions of this licensing are
27 ** not clear to you.
28 **
29 **********************************************************************/
30 
31 #ifndef TEPLUGIN_H
32 #define TEPLUGIN_H
33 
34 #ifndef QT_H
35 #include "qgplugin.h"
36 #include "qstringlist.h"
37 #endif // QT_H
38 #include "teglobal.h"
39 #include <qobject.h>
40 
41 #ifndef QT_NO_COMPONENT
42 
43 class TEBase;
44 class TEPluginPrivate;
45 
46 //#define TE_EXPORT_PLUGIN(pluginobjectname) typedef TEPlugin<pluginobjectname> pluginobjectname##Plugin; Q_EXPORT_PLUGIN(pluginobjectname)
47 #define TE_EXPORT_PLUGIN(pluginobjectname) Q_EXPORT_PLUGIN(pluginobjectname)
48 
56 class LIB_EXPORT TEPluginBase : public QGPlugin
57 {
58  Q_OBJECT
59 public:
60 
61  TEPluginBase();
62  ~TEPluginBase();
63  virtual QStringList keys() const = 0;
64  virtual TEBase *create( const QString &key ) = 0;
65 
66 private:
67  TEPluginPrivate *d;
68 };
69 
70 
71 template<class Type>
72 class TEPlugin : public TEPluginBase
73 {
74 // Q_OBJECT
75 public:
76 
77  TEPlugin()
78  {
79  Type o;
80  extName = o.name();
81  };
82  ~TEPlugin(){};
83  QStringList keys() const
84  {
85  QStringList l;
86  l << extName;
87  return l;
88  };
89  TEBase *create( const QString &key )
90  {
91  if (key == extName) return new Type();
92  return 0;
93  };
94 private:
95  QString extName;
96 };
97 
98 #endif // QT_NO_COMPONENT
99 #endif //TEPLUGIN_H
TEBase * create(const QString &key)
Definition: teplugin.h:89
The TEPlugin class provides an abstract base for custom TEBase plugins.
Definition: teplugin.h:72
Definition: teplugin.h:56
Definition: teplugin.cpp:76
QStringList keys() const
Definition: teplugin.h:83
The TEBase is base class for all trade equipment classes.
Definition: tebase.h:148