Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
scope-path.hpp
Go to the documentation of this file.
1/*
2 SCOPE-PATH.hpp - logical access path down from Session root
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
78#ifndef STEAM_MOBJECT_SESSION_SCOPE_PATH_H
79#define STEAM_MOBJECT_SESSION_SCOPE_PATH_H
80
82#include "lib/iter-adapter.hpp"
83#include "lib/error.hpp"
84
85#include <vector>
86#include <string>
87
88
89namespace lib {
90namespace meta{
91
93
102 template<>
103 struct ValueTypeBinding<vector<Scope>::const_reverse_iterator>
104 {
105 typedef const Scope value_type;
106 typedef Scope const& reference;
107 typedef const Scope* pointer;
108 };
109}}
110
111namespace steam {
112namespace mobject {
113namespace session {
114
115
127 {
128 size_t refcount_;
129 std::vector<Scope> path_;
130
131 typedef vector<Scope> _VType;
132 typedef _VType::const_reverse_iterator _VIter;
134
135 public:
136 ~ScopePath ();
137 ScopePath ();
138 ScopePath (Scope const& leaf);
139
140 ScopePath (ScopePath const&);
141 ScopePath&
142 operator= (ScopePath const&);
143
144 static const ScopePath INVALID;
145
146 explicit operator bool() const { return isValid(); }
147
148
149 /* == state diagnostics == */
150 bool isValid() const;
151 bool empty() const;
152 bool isRoot() const;
153 size_t size() const;
154 size_t length() const;
155 size_t ref_count()const;
156 operator string() const;
157
160 iterator begin() const;
161 iterator end() const;
162
163
164 /* == relations == */
165 Scope const& getLeaf() const;
166 bool endsAt (Scope const&) const;
167 bool contains (Scope const&) const;
168 bool contains (ScopePath const&) const;
169
170 friend ScopePath commonPrefix (ScopePath const&, ScopePath const&);
171 friend bool disjoint (ScopePath const&, ScopePath const&);
172
173 friend bool operator== (ScopePath const&, ScopePath const&);
174
175 friend void intrusive_ptr_add_ref (ScopePath*);
176 friend void intrusive_ptr_release (ScopePath*);
177
178
179 /* == mutations == */
180 void clear();
181 Scope const& moveUp();
182 Scope const& goRoot();
183 void navigate (Scope const&);
184
185
186 private:
187 bool hasValidRoot() const;
188 PlacementMO const& currModelRoot() const;
189 void appendScope (Scope const&);
190 };
191
192
193
194
195
196
197
198 inline bool
199 operator== (ScopePath const& path1, ScopePath const& path2)
200 {
201 return path1.path_ == path2.path_;
202 }
203
204 inline bool
205 operator!= (ScopePath const& path1, ScopePath const& path2)
206 {
207 return not (path1 == path2);
208 }
209
210
214 inline void
216 {
217 REQUIRE (pathFrame);
218 ++(pathFrame->refcount_);
219 }
220
221 inline void
223 {
224 REQUIRE (pathFrame);
225 if (0 < pathFrame->refcount_)
226 --(pathFrame->refcount_);
227 }
228
229
230
231 inline size_t
233 {
234 return refcount_;
235 }
236
237
238 inline size_t
240 {
241 return path_.size();
242 }
243
244
245 inline size_t
247 {
248 return path_.size();
249 }
250
255 inline bool
257 {
258 return path_.empty();
259 }
260
261 inline bool
263 {
264 return (1 == size())
265#if NOBUG_MODE_ALPHA
266 and path_[0].isRoot()
267#endif
268 ;
269 }
270
271
272
278 {
279 return iterator (path_.rbegin(), path_.rend());
280 }
281
284 {
285 return iterator();
286 }
287
288
289}}} // namespace mobject::session
290#endif
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
Sequence of nested scopes within the high-level model.
friend bool operator==(ScopePath const &, ScopePath const &)
_VType::const_reverse_iterator _VIter
bool endsAt(Scope const &) const
verify the scope in question is equivalent to our leaf scope.
friend void intrusive_ptr_add_ref(ScopePath *)
management function for boost::intrusive_ptr to be picked up by ADL
static const ScopePath INVALID
constant invalid path token.
PlacementMO const & currModelRoot() const
friend bool disjoint(ScopePath const &, ScopePath const &)
friend void intrusive_ptr_release(ScopePath *)
_IterType iterator
Iteration is always ascending from leaf to root.
ScopePath & operator=(ScopePath const &)
Copy from existing path.
bool isValid() const
a valid path consists of more than just the root element.
friend ScopePath commonPrefix(ScopePath const &, ScopePath const &)
bool empty() const
an empty path doesn't even contain a root element.
bool contains(Scope const &) const
ScopePath()
Create an empty path.
lib::RangeIter< _VIter > _IterType
A Placement scope within the high-level-model.
Definition scope.hpp:70
Lumiera error handling (C++ interface).
Helper template(s) for creating Lumiera Forward Iterators.
Type re-binding helper template for creating nested typedefs usable by custom containers and iterator...
Implementation namespace for support and library code.
Namespace of Session and user visible high-level objects.
Definition sequence.hpp:65
void intrusive_ptr_add_ref(ScopePath *pathFrame)
management function for boost::intrusive_ptr to be picked up by ADL
bool operator==(LocatingPin const &pin1, LocatingPin const &pin2)
check for equivalent definition of a complete locating chain
void intrusive_ptr_release(ScopePath *pathFrame)
bool operator!=(ScopePath const &path1, ScopePath const &path2)
Steam-Layer implementation namespace root.