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/mobject.hpp"
|
|
|
|
|
//#include "proc/mobject/placement.hpp"
|
|
|
|
|
#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
|
|
|
//#include <vector>
|
|
|
|
|
//#include <string>
|
|
|
|
|
|
|
|
|
|
//using std::vector;
|
|
|
|
|
//using std::string;
|
|
|
|
|
|
|
|
|
|
namespace mobject {
|
|
|
|
|
namespace session {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO type comment
|
|
|
|
|
*/
|
|
|
|
|
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-10-20 05:34:58 +02:00
|
|
|
QueryFocus& reset ();
|
2009-10-20 04:31:50 +02:00
|
|
|
QueryFocus& attach (Scope const&);
|
|
|
|
|
static QueryFocus push (Scope const&);
|
2009-11-20 22:00:15 +01:00
|
|
|
QueryFocus& pop();
|
2009-10-20 04:31:50 +02:00
|
|
|
|
2009-11-20 22:00:15 +01:00
|
|
|
operator Scope() const { return currPath().getLeaf(); }
|
|
|
|
|
ScopePath currentPath() const { return currPath(); } ///< @note returns a copy
|
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
|
|
|
|
|
|
|
|
private:
|
2009-11-22 10:32:08 +01:00
|
|
|
QueryFocus (ScopePath&);
|
|
|
|
|
|
|
|
|
|
static ScopePath& currPath();
|
2009-10-14 05:48:24 +02:00
|
|
|
};
|
|
|
|
|
///////////////////////////TODO currently just fleshing the API
|
2009-10-20 04:31:50 +02:00
|
|
|
|
|
|
|
|
|
2009-11-22 10:32:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/** discover depth-first any matching object
|
|
|
|
|
* within \em current focus. Resolution is
|
|
|
|
|
* 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 10:32:08 +01:00
|
|
|
/** discover any matching object contained
|
|
|
|
|
* as immediate Child within \em current focus.
|
|
|
|
|
* Resolution through \em current session */
|
|
|
|
|
template<class MO>
|
|
|
|
|
typename ScopeQuery<MO>::iterator
|
|
|
|
|
QueryFocus::explore() const
|
|
|
|
|
{
|
|
|
|
|
ScopeLocator::instance().explore<MO> (*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-10-14 05:48:24 +02:00
|
|
|
|
|
|
|
|
}} // namespace mobject::session
|
|
|
|
|
#endif
|