2009-10-14 05:48:24 +02:00
|
|
|
/*
|
|
|
|
|
QUERY-FOCUS.hpp - management of current scope within the Session
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MOBJECT_SESSION_QUERY_FOCUS_H
|
|
|
|
|
#define MOBJECT_SESSION_QUERY_FOCUS_H
|
|
|
|
|
|
|
|
|
|
#include "proc/mobject/session/scope-path.hpp"
|
2009-11-06 18:42:15 +01:00
|
|
|
#include "proc/mobject/session/scope-locator.hpp"
|
2009-10-14 05:48:24 +02:00
|
|
|
|
2009-11-22 10:32:08 +01:00
|
|
|
#include <boost/intrusive_ptr.hpp>
|
2009-10-14 05:48:24 +02:00
|
|
|
|
|
|
|
|
namespace mobject {
|
|
|
|
|
namespace session {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-11-22 11:13:49 +01:00
|
|
|
* Current focus location to use as point-of reference
|
|
|
|
|
* for contents and location discovery queries. This is the
|
|
|
|
|
* frontend to be used by client code: a smart-handle, internally
|
|
|
|
|
* linked through the ScopeLocaor singleton to a stack of current
|
|
|
|
|
* focus path locations. The intention is for this current location
|
|
|
|
|
* to follow the ongoing query/discovery operations mostly automatically.
|
|
|
|
|
*
|
|
|
|
|
* \par usage
|
|
|
|
|
*
|
|
|
|
|
* A QueryFocus (frontend handle) can be default constructed, in which
|
|
|
|
|
* case it will automatically connect to what is currently the focus
|
|
|
|
|
* location for any further queries. Here, the current focus location
|
|
|
|
|
* is defined as the most recently used location which is still referred
|
|
|
|
|
* by some QueryFocus handle.
|
|
|
|
|
*
|
|
|
|
|
* Alternatively, through the static factory function #push(), a new
|
|
|
|
|
* focus location may be opened, thereby pushing the currently used
|
|
|
|
|
* focus location aside. This new focus location will remain the
|
|
|
|
|
* current focus, while any handles referring to it is still in use.
|
|
|
|
|
*
|
|
|
|
|
* Using an existing QueryFocus (handle), the current focus may be
|
|
|
|
|
* shifted to another scope within the current session.
|
|
|
|
|
*
|
|
|
|
|
* The templated query functions allow to issue specifically typed
|
|
|
|
|
* queries to retrieve all children (immediately contained in a
|
|
|
|
|
* given scope), or do discover depth-first any content within
|
|
|
|
|
* this scope. The result set of these queries will be filtered
|
|
|
|
|
* to yield only placements compatible to the specified kind of
|
|
|
|
|
* MObject. E.g, you may query all Clip objects within a given Track.
|
|
|
|
|
*
|
|
|
|
|
* The implementation of these query operations is backed by the
|
|
|
|
|
* PlacementIndex in the current session. The link to the session
|
|
|
|
|
* is established the moment these query functions are invoked.
|
|
|
|
|
* The returned iterator (Lumiera Forward Iterator) contains a
|
|
|
|
|
* smart-ptr to keep the hidden result set alive. The results
|
|
|
|
|
* are delivered without any defined order (implementation is
|
|
|
|
|
* hashtable based)
|
|
|
|
|
*
|
|
|
|
|
* @see query-focus-test.cpp
|
2009-10-14 05:48:24 +02:00
|
|
|
*/
|
|
|
|
|
class QueryFocus
|
|
|
|
|
{
|
2009-11-22 10:32:08 +01:00
|
|
|
boost::intrusive_ptr<ScopePath> focus_;
|
2009-10-14 05:48:24 +02:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
QueryFocus();
|
|
|
|
|
|
2009-11-22 11:13:49 +01:00
|
|
|
ScopePath currentPath() const;
|
|
|
|
|
operator Scope() const;
|
|
|
|
|
|
|
|
|
|
QueryFocus& attach (Scope const&);
|
2009-10-20 04:31:50 +02:00
|
|
|
static QueryFocus push (Scope const&);
|
2009-11-22 11:13:49 +01:00
|
|
|
QueryFocus& reset ();
|
|
|
|
|
QueryFocus& pop ();
|
2009-10-20 04:31:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
template<class MO>
|
2009-11-20 19:58:22 +01:00
|
|
|
typename ScopeQuery<MO>::iterator
|
2009-11-22 10:32:08 +01:00
|
|
|
query() const;
|
2009-11-20 19:58:22 +01:00
|
|
|
|
|
|
|
|
template<class MO>
|
|
|
|
|
typename ScopeQuery<MO>::iterator
|
2009-11-22 10:32:08 +01:00
|
|
|
explore() const;
|
2009-11-20 22:00:15 +01:00
|
|
|
|
2009-11-22 11:13:49 +01:00
|
|
|
|
2009-11-20 22:00:15 +01:00
|
|
|
private:
|
2009-11-22 10:32:08 +01:00
|
|
|
QueryFocus (ScopePath&);
|
|
|
|
|
static ScopePath& currPath();
|
2009-10-14 05:48:24 +02:00
|
|
|
};
|
2009-10-20 04:31:50 +02:00
|
|
|
|
2009-11-22 11:13:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** allowing direct conversion to Scope.
|
|
|
|
|
* Implemented by copying the scope at
|
|
|
|
|
* leaf position of the current focus path
|
|
|
|
|
*/
|
|
|
|
|
QueryFocus::operator Scope() const
|
|
|
|
|
{
|
|
|
|
|
return currPath().getLeaf();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**@note returning a copy */
|
|
|
|
|
ScopePath
|
|
|
|
|
QueryFocus::currentPath() const
|
|
|
|
|
{
|
|
|
|
|
return currPath();
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-22 10:32:08 +01:00
|
|
|
|
|
|
|
|
/** discover depth-first any matching object
|
2009-11-22 11:13:49 +01:00
|
|
|
* within \em current focus. Resolution is
|
2009-11-22 10:32:08 +01:00
|
|
|
* delegate to the \em current session */
|
|
|
|
|
template<class MO>
|
|
|
|
|
typename ScopeQuery<MO>::iterator
|
|
|
|
|
QueryFocus::query() const
|
|
|
|
|
{
|
|
|
|
|
ScopeLocator::instance().query<MO> (*this);
|
|
|
|
|
}
|
2009-10-14 05:48:24 +02:00
|
|
|
|
2009-11-22 11:13:49 +01:00
|
|
|
|
|
|
|
|
/** discover any matching object contained
|
|
|
|
|
* as immediate Child within \em current focus.
|
2009-11-22 10:32:08 +01:00
|
|
|
* Resolution through \em current session */
|
|
|
|
|
template<class MO>
|
|
|
|
|
typename ScopeQuery<MO>::iterator
|
|
|
|
|
QueryFocus::explore() const
|
|
|
|
|
{
|
|
|
|
|
ScopeLocator::instance().explore<MO> (*this);
|
|
|
|
|
}
|
2009-11-22 11:13:49 +01:00
|
|
|
|
|
|
|
|
|
2009-10-14 05:48:24 +02:00
|
|
|
|
|
|
|
|
}} // namespace mobject::session
|
|
|
|
|
#endif
|