libyui  3.2.7
YUILoader.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YUILoader.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YUILoader_h
27 #define YUILoader_h
28 
29 
30 #include <string>
31 
32 #include "YUI.h"
33 #include "YExternalWidgets.h"
34 
35 
36 
37 #define YUIPlugin_Qt "qt"
38 #define YUIPlugin_NCurses "ncurses"
39 #define YUIPlugin_Gtk "gtk"
40 
41 
42 /**
43  * Class to load one of the concrete UI plug-ins: Qt, NCurses, Gtk.
44  **/
45 class YUILoader
46 {
47 public:
48  /**
49  * Load any of the available UI plug-ins in this order:
50  * - Qt if $DISPLAY is set
51  * - NCurses if stdout is a tty
52  **/
53  static void loadUI( bool withThreads = false );
54 
55  /**
56  * This will make sure the UI singleton is deleted.
57  * If the UI is already destroyed, it will do nothing. If
58  * there still is a UI object, it will be deleted.
59  *
60  * This is particularly important for the NCurses UI so that
61  * the terminal settings are properly restored.
62  **/
63  static void deleteUI();
64 
65  /**
66  * Load a UI plug-in. 'name' is one of the YUIPlugin_ -defines above.
67  *
68  * This might throw exceptions.
69  **/
70  static void loadPlugin( const std::string & name, bool withThreads = false );
71 
72  static bool pluginExists( const std::string & pluginBaseName );
73 
74  /**
75  * Load the given External Widgets plugin followed by its graphical extension implementation
76  * in the following order in the same way as loadUI:
77  * - Qt, Gtk or NCurses
78  *
79  * 'name' is the user defined plugin name, graphical extension implementations have to
80  * be called 'name'-qt, 'name'-gtk and 'name'-ncurses. Following this rule plugin
81  * file names are as libyui-XX-YY.so.VER where:
82  * XX is the user defined name
83  * YY is the UI used (ncurses, gtk, qt)
84  * VER is the libyui so version
85  * 'symbol' is the function symbol to be loaded, e.g. YExternalWidgets* 'symbol'(void)
86  * (e.g. default YExternalWidgets* createExternalWidgets(const char *)
87  * see createEWFunction_t definition)
88  **/
89  static void loadExternalWidgets( const std::string & name, const std::string & symbol="_Z21createExternalWidgetsPKc" );
90 
91 private:
92  YUILoader() {}
93  ~YUILoader() {}
94 
95  /**
96  * Used by loadExternalWidgets to load the graphical plugin specialization.
97  *
98  * 'name' is the original plugin name (e.g. the one passed to loadExternalWidgets)
99  * 'plugin_name' is the graphical plugin specialization name (e.g. 'name'-[gtk|ncurses|qt])
100  * 'symbol' is the function symbol to be loaded and executed (e.g. the one passed loadExternalWidgets)
101  * This might throw exceptions:
102  * YUIPluginException if the plugin has not been loaded
103  * specific exception can be thrown by funtion invoked (param symbol)
104  **/
105  static void loadExternalWidgetsPlugin( const std::string& name, const std::string& plugin_name, const std::string& symbol );
106 };
107 
108 
109 /**
110  * Every UI plug-in has to provide a function
111  *
112  * YUI * createUI( bool withThreads )
113  *
114  * that creates a UI of that specific type upon the first call and returns that
115  * singleton for all subsequent calls.
116  **/
117 typedef YUI * (*createUIFunction_t)( bool );
118 
119 /**
120  * Every WE extension plug-in has to provide a function
121  *
122  * YExternalWidgets * createWE( )
123  *
124  * that creates a WE of that specific type upon the first call and returns that
125  * singleton for all subsequent calls.
126  **/
127 typedef YExternalWidgets * (*createEWFunction_t)( const char * );
128 
129 #endif // YUILoader_h
Abstract base class of a libYUI user interface.
Definition: YUI.h:48
static void loadPlugin(const std::string &name, bool withThreads=false)
Load a UI plug-in.
Definition: YUILoader.cc:111
static void loadExternalWidgets(const std::string &name, const std::string &symbol="_Z21createExternalWidgetsPKc")
Load the given External Widgets plugin followed by its graphical extension implementation in the foll...
Definition: YUILoader.cc:159
Class to load one of the concrete UI plug-ins: Qt, NCurses, Gtk.
Definition: YUILoader.h:45
static void deleteUI()
This will make sure the UI singleton is deleted.
Definition: YUILoader.cc:100
Abstract base class of a libYUI Widget Extension interface.
static void loadUI(bool withThreads=false)
Load any of the available UI plug-ins in this order:
Definition: YUILoader.cc:41