Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
scope.cpp
Go to the documentation of this file.
1/*
2 Scope - nested search scope for properties of placement
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
37#include "lib/iter-source.hpp"
39
40#include <vector>
41
42using std::string;
43using std::vector;
44using lib::IterSource;
46
47
48namespace lumiera {
49namespace error {
50 LUMIERA_ERROR_DEFINE (INVALID_SCOPE, "Placement scope invalid and not locatable within model");
51 LUMIERA_ERROR_DEFINE (NO_PARENT_SCOPE, "Parent scope of root not accessible");
52 LUMIERA_ERROR_DEFINE (EMPTY_SCOPE_PATH, "Placement scope not locatable (empty model path)");
53}}
54
55namespace steam {
56namespace mobject {
57namespace session {
58
59
60
64 Scope::Scope (PlacementMO const& constitutingPlacement)
65 : anchor_(constitutingPlacement)
66 { }
67
68 Scope::Scope (PlacementMO::ID const& constitutingPlacement)
69 : anchor_(constitutingPlacement)
70 { }
71
72
74 : anchor_()
75 {
76 REQUIRE (!anchor_.isValid());
77 }
78
79
81 : anchor_(o.anchor_)
82 {
83 ENSURE (anchor_.isValid());
84 }
85
86
87 Scope&
89 {
90 anchor_ = o.anchor_; // note: actually we're just assigning an hash value
91 ENSURE (o.isValid());
92 return *this;
93 }
94
95
97 const Scope Scope::INVALID = Scope();
98
99
100
102 : focusStack_(new QueryFocusStack)
103 { }
104
106
107
110
111
123
124
125 size_t
127 {
128 return focusStack_->size();
129 }
130
131
142 ScopePath&
144 {
145 return focusStack_->top();
146 }
147
148
153 ScopePath&
158
159
174 {
175 ScopePath& currentPath = focusStack_->top();
176 currentPath.navigate (scope);
177 return wrapIter (currentPath.begin());
178 }
179
180
181
183 Scope
184 Scope::containing (PlacementMO const& aPlacement)
185 {
186 return SessionServiceExploreScope::getScope (aPlacement);
187 }
188
189
190 Scope
191 Scope::containing (RefPlacement const& refPlacement)
192 {
193 return containing (*refPlacement);
194 }
195
196
199 {
200 ASSERT (anchor_);
201 return *anchor_;
202 }
203
204
208 Scope
210 {
211 if (isRoot())
212 throw lumiera::error::Invalid ("can't get parent of root scope"
213 , LERR_(NO_PARENT_SCOPE));
214
216 }
217
218
220 bool
225
226
230 bool
232 {
233 return anchor_.isValid();
234 }
235
236
241 Scope::operator string() const
242 {
243 string res("[");
244 res += anchor_->shortID();
245 res += "]";
246 return res;
247 }
248
249
250
251
252
253}}} // namespace steam::mobject::session
Access point to singletons and other kinds of dependencies designated by type.
Definition depend.hpp:281
Iteration source interface to abstract a data source, which then can be accessed through IterAdapter ...
Interface: a facility for resolving (some kind of) queries A concrete subclass has the ability to cre...
A custom stack holding ScopePath »frames«.
lumiera::QueryResolver const & theResolver()
Definition scope.cpp:119
lib::IterSource< constScope >::iterator locate(Scope const &target)
navigate the current QueryFocus scope location.
Definition scope.cpp:173
ScopePath & currPath()
establishes the current query focus location.
Definition scope.cpp:143
std::unique_ptr< QueryFocusStack > focusStack_
static lib::Depend< ScopeLocator > instance
Storage holding the single ScopeLocator instance.
ScopePath & pushPath()
push aside the current focus location and open a new ScopePath frame, to serve as current location un...
Definition scope.cpp:154
Sequence of nested scopes within the high-level model.
A Placement scope within the high-level-model.
Definition scope.hpp:70
static Scope containing(PlacementMO const &aPlacement)
discover the enclosing scope of a given Placement
Definition scope.cpp:184
Scope & operator=(Scope const &)
Definition scope.cpp:88
PlacementMO & getTop() const
Definition scope.cpp:198
Scope getParent() const
retrieve the parent scope which encloses this scope.
Definition scope.cpp:209
Scope()
unlocated NIL scope
Definition scope.cpp:73
bool isValid() const
check if this scope can be located.
Definition scope.cpp:231
static const Scope INVALID
constant invalid scope token.
Definition scope.hpp:83
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.
Definition error.h:71
#define LERR_(_NAME_)
Definition error.hpp:45
Extension module to build an opaque data source, accessible as Lumiera Forward Iterator.
Core abstraction of the Session model: a media object.
_IterT< IT >::Iter wrapIter(IT &&source)
wraps a given Lumiera Forward Iterator, exposing just a IterSource based frontend.
LumieraError< LERR_(INVALID)> Invalid
Definition error.hpp:211
Lumiera public interface.
Definition advice.hpp:102
Namespace of Session and user visible high-level objects.
Definition sequence.hpp:65
Steam-Layer implementation namespace root.
Implementation facility to work with and navigate nested scopes.
framework and to resolve logical queries.
Service to build the notion of a current location within the Sesison model.
Implementation level session API: query a scope.
static PlacementMO & getScope(PlacementMO const &)
static lumiera::QueryResolver const & getResolver()