Lumiera  0.pre.03
»edityourfreedom«
bus-term.hpp
Go to the documentation of this file.
1 /*
2  BUS-TERM.hpp - connection point for UI elements to the UI-Bus
3 
4  Copyright (C) Lumiera.org
5  2015, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but 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 this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
58 #ifndef GUI_CTRL_BUS_TERM_H
59 #define GUI_CTRL_BUS_TERM_H
60 
61 
62 #include "lib/error.hpp"
63 #include "lib/nocopy.hpp"
64 #include "lib/idi/entry-id.hpp"
65 #include "lib/diff/gen-node.hpp"
66 
67 #include <utility>
68 #include <string>
69 
70 
71 namespace lib {
72  namespace diff { class MutationMessage; }
73 }
74 namespace gui {
75 namespace model {
76  class Tangible;
77 }
78 namespace ctrl{
79 
80  using lib::idi::EntryID;
81  using lib::diff::GenNode;
83  using std::string;
84 
85 
105  class BusTerm
107  {
108  protected:
111 
114 
115  public:
116  using ID = EntryID const&;
117 
118  virtual ~BusTerm();
119 
120  virtual void act (GenNode const& command);
121  virtual void note (ID subject, GenNode const& mark);
122  virtual bool mark (ID subject, GenNode const& mark);
123 
124  virtual size_t markAll (GenNode const& mark);
125  virtual bool change (ID subject, MutationMessage&& diff);
126 
127  virtual operator string() const;
128 
129  void note (GenNode const& mark);
130 
131  ID getID() const { return endpointID_; }
132 
133 
134  BusTerm attach (ID, Tangible& newNode);
135 
138  BusTerm(BusTerm&&) = default;
139 
140  protected:
149  BusTerm(ID identity, BusTerm& attached_to)
150  : endpointID_(identity)
151  , theBus_(attached_to)
152  { }
153 
154  virtual BusTerm& routeAdd(ID,Tangible&);
155  virtual void routeDetach(ID) noexcept;
156 
157  bool isShortCircuit(ID) const noexcept;
158  };
159 
160 
161 
162 
164  inline void
165  BusTerm::note (GenNode const& mark)
166  {
167  theBus_.note (this->endpointID_, mark);
168  }
169 
171  inline bool
172  BusTerm::isShortCircuit(ID otherID) const noexcept
173  {
174  return &theBus_ == this
175  or otherID == endpointID_;
176  }
177 
178 
179 
180 }} // namespace gui::ctrl
181 #endif /*GUI_CTRL_BUS_TERM_H*/
type erased baseclass for building a combined hash and symbolic ID.
Definition: entry-id.hpp:135
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:47
Types marked with this mix-in may be moved but not copied.
Definition: nocopy.hpp:58
typed symbolic and hash ID for asset-like position accounting.
Definition: entry-id.hpp:128
EntryID const & ID
Definition: bus-term.hpp:116
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
Implementation namespace for support and library code.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
BusTerm & theBus_
Definition: bus-term.hpp:113
Generic building block for tree shaped (meta)data structures.
BusTerm(ID identity, BusTerm &attached_to)
Definition: bus-term.hpp:149
Lumiera error handling (C++ interface).
Interface common to all UI elements of relevance for the Lumiera application.
Definition: tangible.hpp:165
Bare symbolic and hash ID used for accounting of asset like entries.
connection point at the UI-Bus.
Definition: bus-term.hpp:105
generic data element node within a tree
Definition: gen-node.hpp:213
ID getID() const
Definition: bus-term.hpp:131