LUMIERA.clone/src/proc/mobject/session/scope.cpp

193 lines
4.8 KiB
C++
Raw Normal View History

/*
Scope - nested search scope for properties of placement
Copyright (C) Lumiera.org
2009, Hermann Vosseler <Ichthyostega@web.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
#include "proc/mobject/session/scope.hpp"
#include "proc/mobject/session/scope-locator.hpp"
#include "proc/mobject/session/query-focus-stack.hpp"
2009-11-20 19:58:22 +01:00
#include "proc/mobject/session/session-service-explore-scope.hpp"
#include "proc/mobject/mobject.hpp"
//#include "proc/mobject/session/track.hpp"
//#include "proc/mobject/placement.hpp"
//#include "proc/mobject/session/mobjectfactory.hpp"
namespace mobject {
namespace session {
2010-09-26 06:01:40 +02:00
LUMIERA_ERROR_DEFINE (INVALID_SCOPE, "Placement scope invalid and not locatable within model");
/** conversion of a scope top (placement) into a Scope.
* only allowed if the given Placement is actually attached
* to the session, which will be checked by index access */
Scope::Scope (PlacementMO const& constitutingPlacement)
: anchor_(constitutingPlacement)
{
}
Scope::Scope ()
: anchor_()
{
REQUIRE (!anchor_.isValid());
}
Scope::Scope (Scope const& o)
: anchor_(o.anchor_)
{ }
Scope&
Scope::operator= (Scope const& o)
{
anchor_ = o.anchor_; ////////////////////////////TODO verify correctness
return *this;
}
ScopeLocator::ScopeLocator()
: focusStack_(new QueryFocusStack)
{
TODO ("anything in initialise here?");
}
ScopeLocator::~ScopeLocator() { }
/** Storage holding the single ScopeLocator instance */
lib::Singleton<ScopeLocator> ScopeLocator::instance;
2009-11-20 19:58:22 +01:00
/** @internal the one (and only) access point
* actually to link the system of Scope and QueryFocus
* to the current session, by delegating resolution
* of contents discovery queries to the PlacementIndex
* managed within the session
*/
QueryResolver const&
ScopeLocator::theResolver()
{
return SessionServiceExploreScope::getResolver();
}
/** establishes the \em current query focus location.
* Relies on the state of the QueryFocusStack.
* If there is no current focus location, a new
* one is created, referring to the root Scope.
* @return the current path corresponding to the
* most recently used QueryFocus, which is
* actually still referred from somewhere.
* @note may cause the QueryFocusStack to pop
* path entries no longer in use.
*/
ScopePath&
ScopeLocator::currPath()
2009-11-20 19:58:22 +01:00
{
return focusStack_->top();
2009-11-20 19:58:22 +01:00
}
/** push aside the current focus location
* and open a new ScopePath frame, to serve
* as \em current location until released
*/
ScopePath&
ScopeLocator::pushPath()
{
return focusStack_->push (SessionServiceExploreScope::getScopeRoot());
}
/** discover the enclosing scope of a given Placement */
Scope const&
Scope::containing (PlacementMO const& aPlacement)
{
UNIMPLEMENTED ("scope discovery");
}
Scope const&
Scope::containing (RefPlacement const& refPlacement)
{
return containing (*refPlacement);
}
PlacementMO&
Scope::getTop() const
{
ASSERT (anchor_);
return *anchor_;
}
/** retrieve the parent scope which encloses this scope.
* @throw error::Invalid if this is the root scope
*/
Scope const&
Scope::getParent() const
{
UNIMPLEMENTED ("retrieve the enclosing parent scope");
}
/** @return true if this is the outmost (root) scope */
bool
Scope::isRoot() const
{
UNIMPLEMENTED ("detection of root scope");
}
/** check if this scope can be located.
* An default constructed Scope (i.e without
* defining Placement) can't be located and returns false here */
bool
Scope::isValid() const
{
return anchor_.isValid();
}
/** enumerate the path of nested scopes up to root scope.
* @return an iterator which starts with this scope and
* successively yields outer scopes, stopping at root.
*/
Scope::IterType_
Scope::ascend() const
{
UNIMPLEMENTED ("ascend scope hierarchy up to root");
}
}} // namespace mobject::session