Lumiera  0.pre.03
»edit your freedom«
panel-locator.hpp
Go to the documentation of this file.
1 /*
2  PANEL-LOCATOR.hpp - manage all top level windows
3 
4  Copyright (C)
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
40 #ifndef STAGE_CTRL_PANEL_LOCATOR_H
41 #define STAGE_CTRL_PANEL_LOCATOR_H
42 
43 #include "stage/gtk-base.hpp"
45 #include "lib/format-string.hpp"
46 #include "lib/meta/util.hpp"
47 #include "lib/nocopy.hpp"
48 
49 #include <type_traits>
50 #include <memory>
51 #include <list>
52 
53 
54 namespace stage {
55 namespace workspace {
56  class WorkspaceWindow;
57 }
58 namespace panel {
59  class Panel;
60 }
61 namespace ctrl {
62 
63  namespace error = lumiera::error;
64 
65  using panel::Panel;
66  using util::_Fmt;
67  using std::list;
68 
69 
70 
78  {
80  using WindowList = list<PWindow>;
81 
82  WindowList& windowList_;
83 
84 
85  public:
86  PanelLocator (WindowList&);
87 
99  template<class PAN>
100  PAN& find_or_create();
101 
102 
103  private:
104  panel::Panel& preliminary_impl_PanelLookup (int typeID);
105  };
106 
107 
108 
110  template<class PAN>
111  inline PAN&
112  PanelLocator::find_or_create()
113  {
114  static_assert (std::is_base_of<panel::Panel, PAN>(), "Lumiera Panel subclass expected");
115 
116  int typeID = workspace::PanelManager::findPanelID<PAN>();
117  if (-1 == typeID)
118  throw error::Invalid (_Fmt{"Requested type «%s» not usable as docking panel."}
119  % util::typeStr<PAN>()
120  ,LERR_(WRONG_TYPE));
121 
122  return dynamic_cast<PAN&> (preliminary_impl_PanelLookup (typeID));
123  }
124 
125 
126 
127 }}// namespace stage::ctrl
128 #endif /*STAGE_CTRL_PANEL_LOCATOR_H*/
Simple and lightweight helpers for metaprogramming and type detection.
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
Management of dockable panels.
Front-end for printf-style string template interpolation.
A front-end for using printf-style formatting.
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:190
Mix-Ins to allow or prohibit various degrees of copying and cloning.
The base class for all dockable panels.
Definition: panel.hpp:40
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
The main Lumiera workspace window.
A set of basic GTK includes for the UI.
Service to access, locate or place panels within top-level windows Access- and query front-end to the...