Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
nexus.hpp
Go to the documentation of this file.
1/*
2 NEXUS.hpp - UI-Bus central hub and routing table
3
4 Copyright (C)
5 2015, 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
30#ifndef STAGE_CTRL_NEXUS_H
31#define STAGE_CTRL_NEXUS_H
32
33
34#include "lib/error.hpp"
35#include "lib/nocopy.hpp"
36#include "lib/idi/genfunc.hpp"
41#include "lib/idi/entry-id.hpp"
42
43#include <unordered_map>
44
45
46namespace stage {
47namespace ctrl{
48
49
50
67 class Nexus
68 : public BusTerm
70 {
71 using RoutingTable = std::unordered_map<EntryID, Tangible*, EntryID::UseEmbeddedHash>;
72
74
75
76 protected:
82 virtual bool
83 mark (ID subject, GenNode const& mark) override
84 {
85 auto entry = routingTable_.find (subject);
86 if (entry == routingTable_.end())
87 return false;
88 else
89 {
90 entry->second->mark (mark);
91 return true;
92 }
93 }
94
98 virtual size_t
99 markAll (GenNode const& mark) override
100 {
101 for (auto& entry : routingTable_)
102 this->mark (entry.first, mark);
103 return routingTable_.size();
104 }
105
106
115 virtual bool
116 change (ID subject, MutationMessage&& diff) override
117 {
118 auto entry = routingTable_.find (subject);
119 if (entry == routingTable_.end())
120 return false;
121 else
122 {
123 Tangible& target = *entry->second;
124 lib::diff::DiffApplicator<Tangible> applicator{target};
125 applicator.consume (move(diff));
126 return true;
127 }
128 }
129
130
141 virtual BusTerm&
142 routeAdd (ID identity, Tangible& newNode) override
143 {
144 routingTable_[identity] = &newNode;
145 return *this;
146 }
147
148
152 virtual void
153 routeDetach (ID node) noexcept override
154 {
155 routingTable_.erase (node);
156 }
157
158
159 virtual operator string() const
160 {
161 return lib::idi::instanceTypeID(this);
162 }
163
164
165 public:
166 size_t
167 size() const
168 {
169 return routingTable_.size();
170 }
171
172 explicit
173 Nexus (BusTerm& uplink_to_CoreService, ID identity =lib::idi::EntryID<Nexus>())
174 : BusTerm(identity, uplink_to_CoreService)
175 { }
176
178 {
179 if (0 < size())
180 ERROR (stage, "Some UI components are still connected to the backbone.");
181 }
182 };
183
184
185
186}} // namespace stage::ctrl
187#endif /*STAGE_CTRL_NEXUS_H*/
Attachment point to the UI-Bus.
generic builder to apply a diff description to a given target data structure.
connection point at the UI-Bus.
Definition bus-term.hpp:98
EntryID const & ID
Definition bus-term.hpp:107
Central hub of the UI-Bus.
Definition nexus.hpp:70
Nexus(BusTerm &uplink_to_CoreService, ID identity=lib::idi::EntryID< Nexus >())
Definition nexus.hpp:173
size_t size() const
Definition nexus.hpp:167
virtual bool change(ID subject, MutationMessage &&diff) override
direct a mutation message towards the indicated Tangible.
Definition nexus.hpp:116
virtual size_t markAll(GenNode const &mark) override
broadcast a notification to all connected terminal nodes.
Definition nexus.hpp:99
virtual BusTerm & routeAdd(ID identity, Tangible &newNode) override
add a new down-link connection to the routing table
Definition nexus.hpp:142
virtual void routeDetach(ID node) noexcept override
deactivate and remove a down-link route.
Definition nexus.hpp:153
RoutingTable routingTable_
Definition nexus.hpp:73
std::unordered_map< EntryID, Tangible *, EntryID::UseEmbeddedHash > RoutingTable
Definition nexus.hpp:71
virtual bool mark(ID subject, GenNode const &mark) override
route mark messages down to the individual Tangible.
Definition nexus.hpp:83
Interface common to all UI elements of relevance for the Lumiera application.
Definition tangible.hpp:160
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
Bare symbolic and hash ID used for accounting of asset like entries.
Lumiera error handling (C++ interface).
Generic functions to build identification schemes.
Generic Message with an embedded diff, to describe changes to model elements.
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
Definition genfunc.hpp:116
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
Mix-Ins to allow or prohibit various degrees of copying and cloning.
generic data element node within a tree
Definition gen-node.hpp:224
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
typed symbolic and hash ID for asset-like position accounting.
Definition entry-id.hpp:219
Abstraction: a tangible element of the User Interface.
Concrete implementation to apply structural changes to hierarchical data structures.