Lumiera  0.pre.03
»edit your freedom«
session-impl.cpp
Go to the documentation of this file.
1 /*
2  SessionImpl - 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 
36 #include "lib/error.hpp"
37 
38 
39 namespace steam {
40 namespace mobject {
41 namespace session {
42 
43 
44 
52  , Session( defaultsManager_
53  , elementQueryAPI_
54  , timelineRegistry_
55  , sequenceRegistry_ )
56  , contents_( MObject::create (defaultsManager_))
57  , fixture_(new fixture::Fixture)
58  {
59  INFO (session, "new Session created.");
60  }
61 
62 
67  void
69  {
70  try
71  {
73  }
74  catch (...)
75  {
76  throw error::Fatal ("unexpected exception while clearing the session");
77  }
78  }
79 
80 
81  bool
82  SessionImpl::isValid ()
83  {
84  return true;
85  }
86 
87 
88 
95  MObjectRef
96  SessionImpl::attach (PMO const& placement)
97  {
98  MObjectRef newAttachedInstance;
99  RefPlacement attachmentPoint = QueryFocus().currentPoint();
100  newAttachedInstance.activate(
101  contents_.insert (placement, attachmentPoint));
102  return newAttachedInstance;
103  }
104 
105 
115  bool
116  SessionImpl::detach (PMO const& placement)
117  {
118  bool is_known = contents_.contains (placement);
119  if (is_known)
120  {
121  if (Scope(placement).isRoot())
122  throw error::Invalid ("Can't detach the model root."
123  , LERR_(INVALID_SCOPE));
124 
125  QueryFocus currentFocus;
126  currentFocus.shift (Scope(placement).getParent());
127  contents_.clear (placement);
128  }
129  ENSURE (!contents_.contains (placement));
130  return is_known;
131  }
132 
133 
134  MObjectRef
135  SessionImpl::getRoot()
136  {
137  MObjectRef refRoot;
138  refRoot.activate (contents_.getRoot());
139  return refRoot;
140  }
141 
142 
143 
144  PFixture&
145  SessionImpl::getFixture ()
146  {
147  return fixture_;
148  }
149 
150 
151  void
152  SessionImpl::rebuildFixture ()
153  {
154  UNIMPLEMENTED ("rebuild Fixture");
155  }
156 
157 
158 
159 }}} // namespace steam::mobject::session
Representation of the current scope when navigating the session model.
An active (smart-ptr like) external reference to a specifically placed MObject "instance" within the ...
Definition: mobject-ref.hpp:93
Core abstraction: placement of a media object into session context.
Core abstraction of the Session model: a media object.
PlacementMO & getRoot() const
retrieve the logical root scope
Steam-Layer implementation namespace root.
QueryFocus & shift(Scope const &)
shift this QueryFocus to a container-like scope, causing it to navigate, changing the current ScopePa...
Namespace of Session and user visible high-level objects.
Definition: sequence.hpp:74
A Placement scope within the high-level-model.
Definition: scope.hpp:74
MObject is the interface class for all "Media Objects".
Definition: mobject.hpp:79
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:196
The (current) Session holds all the user visible content to be edited and manipulated within the Lumi...
Definition: session.hpp:109
Collection of implementation components, providing self-contained sub-elements exposed on the public ...
SessionImpl()
create a new empty session with default values.
ID insert(PlacementMO const &newObj, ID targetScope)
Add a new Placement (Object "instance") into the index.
void clear(ID targetScope)
recursively kill a complete scope, including the given element and all children.
Lumiera error handling (C++ interface).
Core factory to generate media objects for use in the Session model.
Session and SessionServices Implementation classes.
MORef & activate(Placement< MO > const &placement)
activate an MObject reference, based on an existing placement, which needs to be contained (added to)...
virtual MObjectRef attach(PMO const &placement) override
attach a copy within the scope of the current QueryFocus point
virtual bool detach(PMO const &placement) override
detach the denoted object (placement) from model, together with any child objects contained in the sc...
Current focus location to use as point-of reference for contents and location discovery queries...