libyui  3.3.2
YExternalWidgets.h
1 /*
2  Copyright (C) 2013 Angelo Naselli <anaselli at linux dot it>
3 
4  This file is part of libyui project
5 
6  This library is free software; you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as
8  published by the Free Software Foundation; either version 2.1 of the
9  License, or (at your option) version 3.0 of the License. This library
10  is distributed in the hope that it will be useful, but WITHOUT ANY
11  WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  License for more details. You should have received a copy of the GNU
14  Lesser General Public License along with this library; if not, write
15  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
16  Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef YExternalWidgets_h
20 #define YExternalWidgets_h
21 #include <map>
22 #include <string>
23 
25 
26 /**
27  * Abstract base class of a libYUI Widget Extension interface.
28  **/
30 {
31  friend class YExternalWidgetsTerminator;
32 
33 protected:
34  /**
35  * Constructor.
36  * 'name' is the plugin name
37  *
38  * throws a YUIException if the plugin 'name' has been alread created
39  **/
40  YExternalWidgets( const std::string& name );
41 
42 public:
43 
44  /**
45  * Destructor.
46  **/
47  virtual ~YExternalWidgets();
48 
49 
50  /**
51  * Access the global YUI external widgets.
52  * 'name' is the plugin name
53  *
54  * if plugin 'name' has not been explicitally loaded by YUILoader::loadExternalWidgets
55  * externalWidgets try loading it (exactly as YUI::ui does) with default function symbol
56  * to be executed (see YUILoader::loadExternalWidgets for explanation)
57  **/
58  static YExternalWidgets * externalWidgets(const std::string& name);
59 
60  /**
61  * Return the external widget factory that provides all the createXY() methods for
62  * user defined widgets.
63  *
64  * This will create the factory upon the first call and return a pointer to
65  * the one and only (singleton) factory upon each subsequent call.
66  * This may throw exceptions if the factory cannot be created.
67  *
68  * It is up to user extend YExternalWidgetFactory to add createXY() methods in
69  * his/her implementation. So once YExternalWidgetFactory is extended with
70  * all the createXY() methods, three sub-plugins must be defined one for each
71  * supported graphical environment, e.g. Gtk, ncurses and QT, following the
72  * libyui implementation rules.
73  *
74  * For instance an external widgets plugin called yui-foo that needs Gtk, ncurses
75  * and QT specialization will require also yui-foo-gtk, yui-foo-ncurses and
76  * yui-foo-qt plugin implementation.
77  *
78  **/
80  static YExternalWidgetFactory * externalWidgetFactory(const std::string& name);
81 
82 protected:
83 
84  /**
85  * Create the external widgets factory that provides all the createXY() methods for
86  *
87  * Derived classes are required to implement this. Usually createXY() is virtual,
88  * real implementation is demanded to derived classes that implement Gtk, ncurses and QT
89  * specialization.
90  **/
92 
93 private:
94  /** Externale widgets plugin name */
95  std::string _name;
96 
97  /** Externale widget factory */
98  YExternalWidgetFactory* _factory;
99 
100  /** plugin instances */
101  static std::map<std::string, YExternalWidgets *> _externalWidgets;
102 };
103 
104 #endif // YExternalWidgets_h
virtual YExternalWidgetFactory * createExternalWidgetFactory()=0
Create the external widgets factory that provides all the createXY() methods for. ...
YExternalWidgets(const std::string &name)
Constructor.
Helper class to make sure the EW is properly shut down.
static YExternalWidgets * externalWidgets(const std::string &name)
Access the global YUI external widgets.
Abstract base class of a libYUI Widget Extension interface.
virtual ~YExternalWidgets()
Destructor.
YExternalWidgetFactory * externalWidgetFactory()
Return the external widget factory that provides all the createXY() methods for user defined widgets...
Abstract widget factory for mandatory widgets.