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)
5  2008, 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 #ifndef STEAM_MOBJECT_SESSION_SESSIONIMPL_H
38 #define STEAM_MOBJECT_SESSION_SESSIONIMPL_H
39 
45 
50 
52 
53 
54 
55 
56 
57 namespace steam {
58 namespace mobject {
59 namespace session {
60 
61  using fixture::PFixture;
62 
63 
68  : protected SessionInterfaceModules
69  , public mobject::Session
70  {
71  PlacementIndex contents_;
72 
73  PFixture fixture_;
74 
75 
76 
77 
78  /* ==== Session API ==== */
79  virtual bool isValid() override;
80  virtual MObjectRef attach (PMO const& placement) override;
81  virtual bool detach (PMO const& placement) override;
82 
83  virtual MObjectRef getRoot() override;
84 
85  virtual PFixture& getFixture() override;
86  virtual void rebuildFixture() override;
87 
88  protected: /* == management API === */
89  SessionImpl ();
90 
91  void clear ();
92  friend class SessManagerImpl;
93 
95  getPlacementIndex()
96  {
97  ENSURE (contents_.isValid());
98  return contents_;
99  }
100 
101  };
102 
103 
104 
105  /* ===== providing internal services for Steam ===== */
106 
107  template<class IMPL>
109  : IMPL
110  {
111  bool
112  isRegisteredID (PMO::ID const& placementID)
113  {
114  return IMPL::getPlacementIndex().contains (placementID); //never throws
115  }
116 
117  PMO&
118  resolveID (PMO::ID const& placementID)
119  {
120  return IMPL::getPlacementIndex().find (placementID); //may throw
121  }
122  };
123 
124 
125 
126 
127  template<class IMPL>
129  : IMPL
130  {
131  PMO::ID const&
132  insertCopy (PMO const& newPlacement, PMO::ID const& scope)
133  {
134  return index().insert (newPlacement,scope);
135  }
136 
137  bool
138  purgeScopeRecursively (PMO::ID const& scope)
139  {
140  size_t siz = index().size();
141  if (index().contains (scope))
142  index().clear (scope);
143 
144  ENSURE (!index().contains (scope) || (scope == index().getRoot().getID()));
145  ENSURE (siz >= index().size());
146  return siz != index().size();
147  }
148 
149  bool
150  detachElement (PMO::ID const& placementID)
151  {
152  return index().remove (placementID);
153  }
154 
155  private:
157  index()
158  {
159  return IMPL::getPlacementIndex();
160  }
161  };
162 
163 
164 
165 
166  template<class IMPL>
168  : IMPL
169  {
171  getScopeQueryResolver()
172  {
173  return resolvingWrapper_;
174  }
175 
176  PlacementMO&
177  getScope (PlacementMO const& placement2locate)
178  {
179  return IMPL::getPlacementIndex().getScope(placement2locate);
180  }
181 
182  PlacementMO&
183  getScope (PlacementMO::ID const& placement2locate)
184  {
185  return IMPL::getPlacementIndex().getScope(placement2locate);
186  }
187 
188  PlacementMO&
189  getScopeRoot()
190  {
191  return IMPL::getPlacementIndex().getRoot();
192  }
193 
194  private:
195  PlacementIndexQueryResolver resolvingWrapper_;
196 
199  struct
200  AccessCurrentIndex
201  {
202  IMPL& accessPoint_;
203  PlacementIndex& operator() (void) { return accessPoint_.getPlacementIndex(); }
204 
205  AccessCurrentIndex (IMPL& impl) : accessPoint_(impl) { }
206  };
207 
208  protected:
210  : resolvingWrapper_(AccessCurrentIndex (*this))
211  { }
212  };
213 
214 
215 
216 
217 
218  template<class IMPL>
220  : IMPL
221  {
223  getPlacementIndex()
224  {
225  if (mockIndex_ && mockIndex_->isValid())
226  return *mockIndex_;
227  else
228  return IMPL::getPlacementIndex();
229  }
230 
231  void
232  reset_PlacementIndex (PlacementIndex* alternativeIndex =0)
233  {
234  mockIndex_ = alternativeIndex;
235  }
236 
237  protected:
239  : mockIndex_(0)
240  { }
241 
242  private:
243  PlacementIndex* mockIndex_;
244  };
245 
246 
247 
248  template<class IMPL>
250  : IMPL
251 // , SessionServiceDefaults
252  {
254  };
255 
256 
257 
258 
259 
260 
262 
276  > // List of the APIs to provide
277  , SessManagerImpl // frontend for access
278  , SessionImpl // implementation base class
279  > //
281 
282 
283 
284 
285 }}} // namespace steam::mobject::session
286 #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:85
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:65
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:100
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.