Lumiera  0.pre.03
»edit your freedom«
session-services.cpp
Go to the documentation of this file.
1 /*
2  SessionServices - accessing Steam-Layer internal session implementation services
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 
49 
53 
55 #include "lib/symbol.hpp"
56 
57 using lib::Symbol;
58 
59 namespace steam {
60 namespace mobject {
61 namespace session {
62 
66  bool
68  {
69  return Session::initFlag
71  }
72 
77  bool
78  SessionServiceFetch::isRegisteredID (PlacementMO::ID const& placementID)
79  {
80  return SessionImplAPI::current->isRegisteredID (placementID);
81  }
82 
83 
95  SessionServiceFetch::resolveID (PlacementMO::ID const& placementID)
96  {
97  return SessionImplAPI::current->resolveID (placementID);
98  }
99 
100 
108  PlacementMO::ID const&
109  SessionServiceMutate::attach_toModel(PMO newPlacement, PID scope)
110  {
111  return SessionImplAPI::current->insertCopy (newPlacement,scope);
112  }
113 
114 
120  bool
122  {
123  return SessionImplAPI::current->purgeScopeRecursively (scope);
124  }
125 
126 
132  bool
134  {
135  return SessionImplAPI::current->detachElement (leafElement);
136  }
137 
138 
139 
140 
141  namespace { // deleter function to clean up test/mock PlacementIndex
142  void
143  remove_testIndex (PlacementIndex* testIdx)
144  {
145  REQUIRE (testIdx);
146  SessionImplAPI::current->reset_PlacementIndex(); // restore default Index from Session
147 
148  testIdx->clear();
149  ASSERT (0 == testIdx->size());
150  delete testIdx;
151  }
152  }
153 
155  PPIdx
157  {
158  Symbol typeID ("dummyRoot");
159  PMO dummyRoot (MObject::create (typeID));
160  PPIdx mockIndex (new PlacementIndex(dummyRoot), &remove_testIndex); // manage instance lifecycle
161  ENSURE (mockIndex);
162  ENSURE (mockIndex->isValid());
163  ENSURE (1 == mockIndex.use_count());
164 
165  SessionImplAPI::current->reset_PlacementIndex (mockIndex.get());
166  return mockIndex;
167  }
168 
169 
171  QueryResolver const&
173  {
174  return SessionImplAPI::current->getScopeQueryResolver();
175  }
176 
177 
179  PlacementMO&
181  {
182  return SessionImplAPI::current->getScope(placementToLocate);
183  }
184 
185 
186  PlacementMO&
187  SessionServiceExploreScope::getScope (PlacementMO::ID const& placementToLocate)
188  {
189  return SessionImplAPI::current->getScope(placementToLocate);
190  }
191 
192 
194  PlacementMO&
196  {
197  return SessionImplAPI::current->getScopeRoot();
198  }
199 
200 
201 
202 }}} // namespace steam::mobject::session
Implementation level session API: query a scope.
static FRONT & current
intended to be hard-wired to SessManagerImpl singleton
static lumiera::QueryResolver const & getResolver()
static bool isRegisteredID(PlacementMO::ID const &)
verify the given placement-ID (hash) is valid, by checking if it refers to a Placement instance curre...
Interface: a facility for resolving (some kind of) queries A concrete subclass has the ability to cre...
Implementation level session API: resolve a Placement by hash-ID.
static session::SessManager & current
access point to the current Session
Definition: session.hpp:129
static PlacementMO & resolveID(PlacementMO::ID const &)
actually retrieve a Placement tracked by the index.
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.
Token or Atom with distinct identity.
Definition: symbol.hpp:126
static PlacementMO & getScope(PlacementMO const &)
Implementation facility for session management.
static bool isAccessible()
is the element-fetch service usable? Effectively this means: is the session up?
Marker types to indicate a literal string and a Symbol.
static PID attach_toModel(PMO, PID)
attach an object by placement onto the session.
Implementation level session API: PlacementIndex mock for tests.
void clear(ID targetScope)
recursively kill a complete scope, including the given element and all children.
Structured compound of Placement instances with lookup capabilities.
Core factory to generate media objects for use in the Session model.
static bool detach_and_clear(PID)
detach the denoted element from the model including all children.
Session and SessionServices Implementation classes.
virtual bool isUp()=0
diagnostics: session interface opened?
static bool initFlag
temporary fix for init problems
Definition: session.hpp:127
static PPIdx install()
Re-define the implicit PlacementIndex temporarily, e.g.
static session::MObjectFactory create
Storage for the (single, static) MObject factory object.
Definition: mobject.hpp:98
Implementation level session API: add or remove Session contents.
static bool detach(PID)
detach the denoted leaf element from the model.
Implementation level session API: to manage default configured objects.