Lumiera  0.pre.03
»edit your freedom«
session-impl.hpp
Go to the documentation of this file.
1 /*
2  SESSION-IMPL.hpp - holds the complete session data to be edited by the user
3 
4  Copyright (C) Lumiera.org
5  2008, 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 
46 #ifndef STEAM_MOBJECT_SESSION_SESSIONIMPL_H
47 #define STEAM_MOBJECT_SESSION_SESSIONIMPL_H
48 
54 
59 
61 
62 
63 
64 
65 
66 namespace steam {
67 namespace mobject {
68 namespace session {
69 
70  using fixture::PFixture;
71 
72 
77  : protected SessionInterfaceModules
78  , public mobject::Session
79  {
80  PlacementIndex contents_;
81 
82  PFixture fixture_;
83 
84 
85 
86 
87  /* ==== Session API ==== */
88  virtual bool isValid() override;
89  virtual MObjectRef attach (PMO const& placement) override;
90  virtual bool detach (PMO const& placement) override;
91 
92  virtual MObjectRef getRoot() override;
93 
94  virtual PFixture& getFixture() override;
95  virtual void rebuildFixture() override;
96 
97  protected: /* == management API === */
98  SessionImpl ();
99 
100  void clear ();
101  friend class SessManagerImpl;
102 
104  getPlacementIndex()
105  {
106  ENSURE (contents_.isValid());
107  return contents_;
108  }
109 
110  };
111 
112 
113 
114  /* ===== providing internal services for Steam ===== */
115 
116  template<class IMPL>
118  : IMPL
119  {
120  bool
121  isRegisteredID (PMO::ID const& placementID)
122  {
123  return IMPL::getPlacementIndex().contains (placementID); //never throws
124  }
125 
126  PMO&
127  resolveID (PMO::ID const& placementID)
128  {
129  return IMPL::getPlacementIndex().find (placementID); //may throw
130  }
131  };
132 
133 
134 
135 
136  template<class IMPL>
138  : IMPL
139  {
140  PMO::ID const&
141  insertCopy (PMO const& newPlacement, PMO::ID const& scope)
142  {
143  return index().insert (newPlacement,scope);
144  }
145 
146  bool
147  purgeScopeRecursively (PMO::ID const& scope)
148  {
149  size_t siz = index().size();
150  if (index().contains (scope))
151  index().clear (scope);
152 
153  ENSURE (!index().contains (scope) || (scope == index().getRoot().getID()));
154  ENSURE (siz >= index().size());
155  return siz != index().size();
156  }
157 
158  bool
159  detachElement (PMO::ID const& placementID)
160  {
161  return index().remove (placementID);
162  }
163 
164  private:
166  index()
167  {
168  return IMPL::getPlacementIndex();
169  }
170  };
171 
172 
173 
174 
175  template<class IMPL>
177  : IMPL
178  {
180  getScopeQueryResolver()
181  {
182  return resolvingWrapper_;
183  }
184 
185  PlacementMO&
186  getScope (PlacementMO const& placement2locate)
187  {
188  return IMPL::getPlacementIndex().getScope(placement2locate);
189  }
190 
191  PlacementMO&
192  getScope (PlacementMO::ID const& placement2locate)
193  {
194  return IMPL::getPlacementIndex().getScope(placement2locate);
195  }
196 
197  PlacementMO&
198  getScopeRoot()
199  {
200  return IMPL::getPlacementIndex().getRoot();
201  }
202 
203  private:
204  PlacementIndexQueryResolver resolvingWrapper_;
205 
208  struct
209  AccessCurrentIndex
210  {
211  IMPL& accessPoint_;
212  PlacementIndex& operator() (void) { return accessPoint_.getPlacementIndex(); }
213 
214  AccessCurrentIndex (IMPL& impl) : accessPoint_(impl) { }
215  };
216 
217  protected:
219  : resolvingWrapper_(AccessCurrentIndex (*this))
220  { }
221  };
222 
223 
224 
225 
226 
227  template<class IMPL>
229  : IMPL
230  {
232  getPlacementIndex()
233  {
234  if (mockIndex_ && mockIndex_->isValid())
235  return *mockIndex_;
236  else
237  return IMPL::getPlacementIndex();
238  }
239 
240  void
241  reset_PlacementIndex (PlacementIndex* alternativeIndex =0)
242  {
243  mockIndex_ = alternativeIndex;
244  }
245 
246  protected:
248  : mockIndex_(0)
249  { }
250 
251  private:
252  PlacementIndex* mockIndex_;
253  };
254 
255 
256 
257  template<class IMPL>
259  : IMPL
260 // , SessionServiceDefaults
261  {
263  };
264 
265 
266 
267 
268 
269 
271 
285  > // List of the APIs to provide
286  , SessManagerImpl // frontend for access
287  , SessionImpl // implementation base class
288  > //
290 
291 
292 
293 
294 }}} // namespace steam::mobject::session
295 #endif
Implementation level session API: query a scope.
An active (smart-ptr like) external reference to a specifically placed MObject "instance" within the ...
Definition: mobject-ref.hpp:94
Collection of configured implementation-level services to provide by the Session. ...
Wrapper for the PlacementIndex, allowing to resolve scope contents discovery.
Interface: a facility for resolving (some kind of) queries A concrete subclass has the ability to cre...
Access point to a single implementation-level API.
Backbone data structure of the low-level render node model The fixture defines the boundary between t...
Implementation-level service for resolving an Placement-ID.
Implementation level session API: resolve a Placement by hash-ID.
Implementation-level service for issuing contents/discovery queries.
Steam-Layer implementation namespace root.
Namespace of Session and user visible high-level objects.
Definition: sequence.hpp:74
A mechanism for exposing and accessing implementation level services of the session.
The (current) Session holds all the user visible content to be edited and manipulated within the Lumi...
Definition: session.hpp:109
Core of the session implementation datastructure.
Collection of implementation components, providing self-contained sub-elements exposed on the public ...
Self-contained sub-elements on the Session API.
Session manager implementation class holding the actual smart pointer to the current Session impl...
there is an implicit PlacementIndex available on a global level, by default implemented within the cu...
Implementation-level service for resolving an Placement-ID.
SessionImpl()
create a new empty session with default values.
SessionServices< Types< SessionServiceFetch, SessionServiceMutate, SessionServiceExploreScope, SessionServiceMockIndex, SessionServiceDefaults >, SessManagerImpl, SessionImpl > SessionImplAPI
actual configuration of the session implementation compound: forming an inheritance chain of all inte...
bool isValid() const
validity self-check, used for sanity checks and the session self-check.
Implementation level session API: PlacementIndex mock for tests.
Structured compound of Placement instances with lookup capabilities.
Implementing resolution of "discover contents"-queries based on PlacementIndex.
virtual MObjectRef attach(PMO const &placement) override
attach a copy within the scope of the current QueryFocus point
Primary Interface to the current Session.
virtual bool detach(PMO const &placement) override
detach the denoted object (placement) from model, together with any child objects contained in the sc...
Implementation level session API: to manage default configured objects.
Implementation class for the Session interface.