Debian Codegraph @

src/Gui/WorkbenchManager.h

raw
1 /***************************************************************************
2 * Copyright (c) 2005 Werner Mayer <wmayer[at]users.sourceforge.net> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23
24 #ifndef GUI_WORKBENCHMANAGER_H
25 #define GUI_WORKBENCHMANAGER_H
26
27 #include <list>
28 #include <map>
29 #include <string>
30 #include <FCGlobal.h>
31
32 namespace Gui
33 {
34
35 class Workbench;
36
37 /**
38 * The WorkbenchManager class manages all workbench objects.
39 * @author Werner Mayer
40 */
41 class GuiExport WorkbenchManager
42 {
43 public:
44 /** Creates the only instance of the WorkbenchManager. */
45 static WorkbenchManager* instance();
46 static void destruct();
47
48 /** Searches for and returns an existing workbench object with name \a name. If no
49 * such workbench exists then a workbench of class \a className gets created, if possible.
50 * If the workbench cannot be created 0 is returned.
51 */
52 Workbench* createWorkbench(const std::string& name, const std::string& className);
53 /** Removes the workbench with name \a name. If there is no such
54 * workbench exists nothing happens.
55 */
56 void removeWorkbench(const std::string& name);
57 /** Returns an instance of the workbench with name \a name. If there is
58 * no such workbench 0 is returned.
59 */
60 Workbench* getWorkbench(const std::string& name) const;
61 /** Activates the workbench with name \a name. */
62 bool activate(const std::string& name, const std::string& className);
63 /** Returns the active workbench. */
64 Workbench* active() const;
65 /** Returns the name of the active workbench. */
66 std::string activeName() const;
67 /** Returns a list of all created workbench objects. */
68 std::list<std::string> workbenches() const;
69
70 protected:
71 WorkbenchManager();
72 ~WorkbenchManager();
73
74 private:
75 static WorkbenchManager* _instance;
76 Workbench* _activeWorkbench {nullptr};
77 std::map<std::string, Workbench*> _workbenches;
78 };
79
80 } // namespace Gui
81
82
83 #endif // GUI_WORKBENCHMANAGER_H