2009-11-04 04:56:25 +01:00
|
|
|
/*
|
|
|
|
|
SCOPE-LOCATOR.hpp - management and registration point for the QueryFocus-system
|
|
|
|
|
|
|
|
|
|
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_SCOPE_LOCATOR_H
|
|
|
|
|
#define MOBJECT_SESSION_SCOPE_LOCATOR_H
|
|
|
|
|
|
|
|
|
|
//#include "proc/mobject/mobject.hpp"
|
|
|
|
|
#include "proc/mobject/session/scope.hpp"
|
|
|
|
|
#include "proc/mobject/placement.hpp"
|
2009-11-07 02:49:55 +01:00
|
|
|
#include "proc/mobject/session/scope-query.hpp"
|
2009-11-04 04:56:25 +01:00
|
|
|
#include "lib/singleton.hpp"
|
|
|
|
|
#include "lib/util.hpp"
|
|
|
|
|
|
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
#include <tr1/memory>
|
|
|
|
|
//#include <vector>
|
|
|
|
|
//#include <string>
|
|
|
|
|
|
|
|
|
|
//using std::vector;
|
|
|
|
|
//using std::string;
|
|
|
|
|
|
|
|
|
|
namespace mobject {
|
|
|
|
|
namespace session {
|
|
|
|
|
|
|
|
|
|
using std::tr1::shared_ptr;
|
|
|
|
|
using boost::scoped_ptr;
|
|
|
|
|
using util::cStr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QueryFocusStack; //////TODO better include?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ScopeLocator
|
|
|
|
|
{
|
2009-11-06 18:42:15 +01:00
|
|
|
scoped_ptr<QueryFocusStack> focusStack_;
|
2009-11-04 04:56:25 +01:00
|
|
|
|
|
|
|
|
public:
|
2009-11-06 18:42:15 +01:00
|
|
|
static lib::Singleton<ScopeLocator> instance;
|
2009-11-04 04:56:25 +01:00
|
|
|
|
2009-11-20 19:58:22 +01:00
|
|
|
QueryFocus currFocus();
|
2009-11-04 04:56:25 +01:00
|
|
|
|
|
|
|
|
template<typename MO>
|
2009-11-20 19:58:22 +01:00
|
|
|
typename ScopeQuery<MO>::iterator
|
2009-11-06 18:42:15 +01:00
|
|
|
explore (Scope);
|
|
|
|
|
|
2009-11-20 19:58:22 +01:00
|
|
|
template<typename MO>
|
|
|
|
|
typename ScopeQuery<MO>::iterator
|
|
|
|
|
query (Scope);
|
|
|
|
|
|
2009-11-06 18:42:15 +01:00
|
|
|
protected:
|
|
|
|
|
ScopeLocator();
|
2009-11-04 04:56:25 +01:00
|
|
|
|
2009-11-06 18:42:15 +01:00
|
|
|
friend class lib::singleton::StaticCreate<ScopeLocator>;
|
2009-11-20 19:58:22 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QueryResolver const& theResolver();
|
2009-11-04 04:56:25 +01:00
|
|
|
};
|
|
|
|
|
///////////////////////////TODO currently just fleshing the API
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-20 19:58:22 +01:00
|
|
|
|
|
|
|
|
/** use the currently installed contents-resolving facility
|
|
|
|
|
* to enumerate the contents (children) of the given scope
|
2009-11-04 04:56:25 +01:00
|
|
|
*/
|
2009-11-20 19:58:22 +01:00
|
|
|
template<typename MO>
|
|
|
|
|
inline typename ScopeQuery<MO>::iterator
|
|
|
|
|
ScopeLocator::explore (Scope scope)
|
2009-11-04 04:56:25 +01:00
|
|
|
{
|
2009-11-20 19:58:22 +01:00
|
|
|
return ScopeQuery<MO> (theResolver(), scope.getTop(), CHILDREN);
|
2009-11-04 04:56:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** use the currently installed contents-resolving facility
|
2009-11-20 19:58:22 +01:00
|
|
|
* to discover depth-first any object within this scope
|
2009-11-04 04:56:25 +01:00
|
|
|
*/
|
|
|
|
|
template<typename MO>
|
2009-11-20 19:58:22 +01:00
|
|
|
inline typename ScopeQuery<MO>::iterator
|
|
|
|
|
ScopeLocator::query (Scope scope)
|
2009-11-04 04:56:25 +01:00
|
|
|
{
|
2009-11-20 19:58:22 +01:00
|
|
|
return ScopeQuery<MO> (theResolver(), scope.getTop(), CONTENTS);
|
2009-11-04 04:56:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}} // namespace mobject::session
|
|
|
|
|
#endif
|