GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
gtk-manager.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2007-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_gtk_manager_h)
24 #define octave_gtk_manager_h 1
25 
26 #include "octave-config.h"
27 
28 #include <map>
29 #include <set>
30 #include <string>
31 
32 #include "Cell.h"
33 #include "graphics-toolkit.h"
34 
35 namespace octave
36 {
38  {
39  public:
40 
41  gtk_manager (void) { }
42 
43  ~gtk_manager (void)
44  {
46  }
47 
48  graphics_toolkit get_toolkit (void) const;
49 
50  void register_toolkit (const std::string& name);
51 
52  void unregister_toolkit (const std::string& name);
53 
54  void load_toolkit (const graphics_toolkit& tk)
55  {
56  loaded_toolkits[tk.get_name ()] = tk;
57  }
58 
60  {
61  loaded_toolkits.erase (name);
62  }
63 
65  {
67 
68  if (p != loaded_toolkits.end ())
69  return p->second;
70  else
71  return graphics_toolkit ();
72  }
73 
75  {
76  Cell m (1, available_toolkits.size ());
77 
78  octave_idx_type i = 0;
79  for (const auto& tkit : available_toolkits)
80  m(i++) = tkit;
81 
82  return m;
83  }
84 
86  {
87  Cell m (1, loaded_toolkits.size ());
88 
89  octave_idx_type i = 0;
90  for (const auto& nm_tkit_p : loaded_toolkits)
91  m(i++) = nm_tkit_p.first;
92 
93  return m;
94  }
95 
96  void unload_all_toolkits (void)
97  {
98  while (! loaded_toolkits.empty ())
99  {
101 
102  std::string name = p->first;
103 
104  p->second.close ();
105 
106  // The toolkit may have unloaded itself. If not, we'll do it here.
107  if (loaded_toolkits.find (name) != loaded_toolkits.end ())
109  }
110  }
111 
112  std::string default_toolkit (void) const { return dtk; }
113 
114  private:
115 
116  // The name of the default toolkit.
118 
119  // The list of toolkits that we know about.
120  std::set<std::string> available_toolkits;
121 
122  // The list of toolkits we have actually loaded.
123  std::map<std::string, graphics_toolkit> loaded_toolkits;
124 
125  typedef std::set<std::string>::iterator available_toolkits_iterator;
126 
127  typedef std::set<std::string>::const_iterator
129 
130  typedef std::map<std::string, graphics_toolkit>::iterator
132 
133  typedef std::map<std::string, graphics_toolkit>::const_iterator
135  };
136 }
137 
138 #endif
void unload_toolkit(const std::string &name)
Definition: gtk-manager.h:59
Definition: Cell.h:37
graphics_toolkit find_toolkit(const std::string &name) const
Definition: gtk-manager.h:64
void load_toolkit(const graphics_toolkit &tk)
Definition: gtk-manager.h:54
std::set< std::string > available_toolkits
Definition: gtk-manager.h:120
void unregister_toolkit(const std::string &name)
Definition: gtk-manager.cc:82
std::map< std::string, graphics_toolkit >::const_iterator const_loaded_toolkits_iterator
Definition: gtk-manager.h:134
Cell available_toolkits_list(void) const
Definition: gtk-manager.h:74
std::string default_toolkit(void) const
Definition: gtk-manager.h:112
void unload_all_toolkits(void)
Definition: gtk-manager.h:96
nd deftypefn *std::string name
Definition: sysdep.cc:647
std::set< std::string >::const_iterator const_available_toolkits_iterator
Definition: gtk-manager.h:128
std::string get_name(void) const
void register_toolkit(const std::string &name)
Definition: gtk-manager.cc:71
std::map< std::string, graphics_toolkit > loaded_toolkits
Definition: gtk-manager.h:123
p
Definition: lu.cc:138
for i
Definition: data.cc:5264
graphics_toolkit get_toolkit(void) const
Definition: gtk-manager.cc:36
Cell loaded_toolkits_list(void) const
Definition: gtk-manager.h:85
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
std::map< std::string, graphics_toolkit >::iterator loaded_toolkits_iterator
Definition: gtk-manager.h:131
std::set< std::string >::iterator available_toolkits_iterator
Definition: gtk-manager.h:125