Lumiera  0.pre.03
»edit your freedom«
query-focus.cpp
Go to the documentation of this file.
1 /*
2  QueryFocus - management of current scope within the Session
3 
4  Copyright (C) Lumiera.org
5  2009, 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 
32 #include "lib/format-string.hpp"
33 
34 using util::_Fmt;
35 
36 namespace steam {
37 namespace mobject {
38 namespace session {
39 
40 
41 
51  : focus_( & currPath())
52  { }
53 
54 
60  : focus_( &path_to_attach)
61  { }
62 
63 
66  ScopePath&
68  {
69  return ScopeLocator::instance().currPath();
70  }
71 
72 
76  QueryFocus&
78  {
79  REQUIRE (focus_);
80  focus_->clear();
81  return *this;
82  }
83 
84 
85 
86 
87 
88  namespace {// error check shortcut....
89 
91 
92  void
93  ___check_validTaget (Scope const& target)
94  {
95  if (!target.isValid())
96  throw Invalid{"Invalid target location for QueryFocus"
97  , LERR_(INVALID_SCOPE)};
98  }
99  }//(End) shortcut
100 
101 
102 
109  QueryFocus&
110  QueryFocus::shift (Scope const& container)
111  {
112  ___check_validTaget (container);
113 
114  REQUIRE (focus_);
115  focus_->navigate (container);
116  return *this;
117  }
118 
119 
124  QueryFocus
125  QueryFocus::push (Scope const& otherContainer)
126  {
127  ___check_validTaget (otherContainer);
128 
129  QueryFocus newFocus (ScopeLocator::instance().pushPath());
130  newFocus.shift (otherContainer);
131  return newFocus;
132  }
133 
134 
137  QueryFocus
139  {
140  Scope currentLocation (ScopeLocator::instance().currPath().getLeaf());
141  ENSURE (currentLocation.isValid());
142 
143  QueryFocus newFocus (ScopeLocator::instance().pushPath());
144  newFocus.shift (currentLocation);
145  return newFocus;
146  }
147 
148 
149 
156  QueryFocus&
158  {
159  focus_ = 0;
160  focus_ = & currPath();
161 
162  return *this;
163  }
164 
165 
166 
168  QueryFocus::operator string() const
169  {
170  static _Fmt display("Focus(%d)--->%s");
171  return display % ScopeLocator::instance().stackSize()
172  % *focus_;
173  }
174 
175 
176 
177 }}} // namespace steam::mobject::session
Representation of the current scope when navigating the session model.
Front-end for printf-style string template interpolation.
Core abstraction of the Session model: a media object.
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
QueryFocus & shift(Scope const &)
shift this QueryFocus to a container-like scope, causing it to navigate, changing the current ScopePa...
Namespace of Session and user visible high-level objects.
Definition: sequence.hpp:74
Sequence of nested scopes within the high-level model.
Definition: scope-path.hpp:135
QueryFocus & pop()
cease to use this specific reference to the current frame.
A Placement scope within the high-level-model.
Definition: scope.hpp:78
bool isValid() const
check if this scope can be located.
Definition: scope.cpp:240
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:199
QueryFocus & reset()
discard any state and navigate current focus path to model root
Definition: query-focus.cpp:77
static lib::Depend< ScopeLocator > instance
Storage holding the single ScopeLocator instance.
Current focus location to use as point-of reference for contents and location discovery queries...
QueryFocus()
create a new QueryFocus (handle) linked to the current focus for discovery queries.
Definition: query-focus.cpp:50
static QueryFocus push()
push the "current QueryFocus" aside and open a new focus frame, which starts out at the same location...