Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
query-focus.cpp
Go to the documentation of this file.
1/*
2 QueryFocus - 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
23#include "lib/format-string.hpp"
24
25using util::_Fmt;
26
27namespace steam {
28namespace mobject {
29namespace session {
30
31
32
42 : focus_( & currPath())
43 { }
44
45
51 : focus_( &path_to_attach)
52 { }
53
54
59 {
60 return ScopeLocator::instance().currPath();
61 }
62
63
69 {
70 REQUIRE (focus_);
71 focus_->clear();
72 return *this;
73 }
74
75
76
77
78
79 namespace {// error check shortcut....
80
82
83 void
84 ___check_validTaget (Scope const& target)
85 {
86 if (!target.isValid())
87 throw Invalid{"Invalid target location for QueryFocus"
88 , LERR_(INVALID_SCOPE)};
89 }
90 }//(End) shortcut
91
92
93
100 QueryFocus&
101 QueryFocus::shift (Scope const& container)
102 {
103 ___check_validTaget (container);
104
105 REQUIRE (focus_);
106 focus_->navigate (container);
107 return *this;
108 }
109
110
116 QueryFocus::push (Scope const& otherContainer)
117 {
118 ___check_validTaget (otherContainer);
119
120 QueryFocus newFocus (ScopeLocator::instance().pushPath());
121 newFocus.shift (otherContainer);
122 return newFocus;
123 }
124
125
130 {
131 Scope currentLocation (ScopeLocator::instance().currPath().getLeaf());
132 ENSURE (currentLocation.isValid());
133
134 QueryFocus newFocus (ScopeLocator::instance().pushPath());
135 newFocus.shift (currentLocation);
136 return newFocus;
137 }
138
139
140
149 {
150 focus_ = 0;
151 focus_ = & currPath();
152
153 return *this;
154 }
155
156
157
159 QueryFocus::operator string() const
160 {
161 static _Fmt display("Focus(%d)--->%s");
162 return display % ScopeLocator::instance().stackSize()
163 % *focus_;
164 }
165
166
167
168}}} // namespace steam::mobject::session
Derived specific exceptions within Lumiera's exception hierarchy.
Definition error.hpp:193
Current focus location to use as point-of reference for contents and location discovery queries.
QueryFocus & shift(Scope const &)
shift this QueryFocus to a container-like scope, causing it to navigate, changing the current ScopePa...
QueryFocus()
create a new QueryFocus (handle) linked to the current focus for discovery queries.
QueryFocus & pop()
cease to use this specific reference to the current frame.
QueryFocus & reset()
discard any state and navigate current focus path to model root
static QueryFocus push()
push the "current QueryFocus" aside and open a new focus frame, which starts out at the same location...
boost::intrusive_ptr< ScopePath > focus_
static lib::Depend< ScopeLocator > instance
Storage holding the single ScopeLocator instance.
Sequence of nested scopes within the high-level model.
A Placement scope within the high-level-model.
Definition scope.hpp:70
bool isValid() const
check if this scope can be located.
Definition scope.cpp:231
A front-end for using printf-style formatting.
#define LERR_(_NAME_)
Definition error.hpp:45
Front-end for printf-style string template interpolation.
Core abstraction of the Session model: a media object.
Namespace of Session and user visible high-level objects.
Definition sequence.hpp:65
Steam-Layer implementation namespace root.
Representation of the current scope when navigating the session model.