Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
query-focus-stack.hpp
Go to the documentation of this file.
1/*
2 QUERY-FOCUS-STACK.hpp - management of current scope within the Session
3
4 Copyright (C)
5 2009, 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
22#ifndef MOBJECT_SESSION_QUERY_FOCUS_STACK_H
23#define MOBJECT_SESSION_QUERY_FOCUS_STACK_H
24
26#include "lib/nocopy.hpp"
27
28#include <list>
29
30using std::list;
31
32
33namespace steam {
34namespace mobject {
35namespace session {
36
37
38
62 {
63
64 std::list<ScopePath> paths_;
65
66 public:
68 : paths_()
69 {
71 }
72
73
74 bool empty () const;
75 size_t size () const;
76
77 ScopePath& push (Scope const&);
78 ScopePath& top ();
79 void pop_unused ();
80 void clear ();
81
82
83 private:
84 void openDefaultFrame ();
85 };
86
87
88
89
90
91
92
93 /* __implementation__ */
94
95 bool
97 {
98 return paths_.empty();
99 }
100
101
102 size_t
104 {
105 return paths_.size();
106 }
107
108
109 void
111 {
112 paths_.clear();
114 }
115
116
124 ScopePath&
125 QueryFocusStack::push (Scope const& newStartPoint)
126 {
127 ScopePath newPathFrame (newStartPoint); // may throw
128 ENSURE (newPathFrame.isValid() or newStartPoint.isRoot());
129
130 paths_.push_back (newPathFrame);
131 ENSURE (0 < size());
132 return paths_.back();
133 }
134
135
140 ScopePath&
142 {
143 if ( 0 == size()
144 or 0 == paths_.back().ref_count()
145 )
146 pop_unused();
147
148 ENSURE (!empty());
149 return paths_.back();
150 }
151
152
160 void
162 {
163 if (1 == size() and not paths_.front().isValid())
164 return; // unnecessary to evict a base frame repeatedly
165
166 while (size() and (0 == paths_.back().ref_count()))
167 paths_.pop_back();
168
169 if (0 == size())
171 ENSURE (!empty());
172 }
173
174
179 void
181 {
182 REQUIRE (0 == size());
183
184 paths_.resize(1);
185
186 ENSURE (not paths_.front().empty());
187 ENSURE (not paths_.front().isValid()); // i.e. just root scope
188 }
189
190
191
192
193}}} // namespace mobject::session
194#endif /*MOBJECT_SESSION_QUERY_FOCUS_STACK_H*/
A custom stack holding ScopePath »frames«.
ScopePath & push(Scope const &)
Open a new path frame, pushing down the current frame.
void pop_unused()
investigate the stack top and discard any path frames which aren't referred anymore (as indicated by ...
Sequence of nested scopes within the high-level model.
bool isValid() const
a valid path consists of more than just the root element.
A Placement scope within the high-level-model.
Definition scope.hpp:70
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
Namespace of Session and user visible high-level objects.
Definition sequence.hpp:65
Steam-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
An Object representing a sequence of nested scopes within the Session.