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)
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 
25 using util::_Fmt;
26 
27 namespace steam {
28 namespace mobject {
29 namespace session {
30 
31 
32 
42  : focus_( & currPath())
43  { }
44 
45 
51  : focus_( &path_to_attach)
52  { }
53 
54 
57  ScopePath&
59  {
60  return ScopeLocator::instance().currPath();
61  }
62 
63 
67  QueryFocus&
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 
115  QueryFocus
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 
128  QueryFocus
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 
147  QueryFocus&
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
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:65
Sequence of nested scopes within the high-level model.
Definition: scope-path.hpp:126
QueryFocus & pop()
cease to use this specific reference to the current frame.
A Placement scope within the high-level-model.
Definition: scope.hpp:69
bool isValid() const
check if this scope can be located.
Definition: scope.cpp:231
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:190
QueryFocus & reset()
discard any state and navigate current focus path to model root
Definition: query-focus.cpp:68
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:41
static QueryFocus push()
push the "current QueryFocus" aside and open a new focus frame, which starts out at the same location...