start definition of new session::Scope interface
This commit is contained in:
parent
d193fbf920
commit
9451a6888f
11 changed files with 383 additions and 20 deletions
|
|
@ -135,6 +135,13 @@ namespace mobject {
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
PlacementIndex::clear()
|
||||
{
|
||||
UNIMPLEMENTED ("purge the PlacementIndex, discarding any contained placements");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace { // implementation detail: default global placement index access
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ namespace mobject {
|
|||
|
||||
~PlacementIndex();
|
||||
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
PlacementIndex() ;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
** these cases will just be a subclass or Placement<MObject>
|
||||
** (which in the mentioned example would mean it couldn't be
|
||||
** passed to a API function expecting a Placement<Meta>).
|
||||
** This is uggly, but doesn't seem to bear any danger.
|
||||
** This is ugly, but doesn't seem to bear any danger.
|
||||
**
|
||||
** @see Placement
|
||||
** @see PlacementRef_test
|
||||
|
|
@ -71,6 +71,7 @@ namespace mobject {
|
|||
LUMIERA_ERROR_DECLARE (INVALID_PLACEMENTREF); ///< unresolvable placement reference, or of incompatible type
|
||||
|
||||
/**
|
||||
* TODO type comment
|
||||
*/
|
||||
template<class MO =MObject>
|
||||
class PlacementRef
|
||||
|
|
|
|||
54
src/proc/mobject/session/scope.cpp
Normal file
54
src/proc/mobject/session/scope.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
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/mobject.hpp"
|
||||
//#include "proc/mobject/session/track.hpp"
|
||||
//#include "proc/mobject/placement.hpp"
|
||||
//#include "proc/mobject/session/mobjectfactory.hpp"
|
||||
//#include "proc/asset/track.hpp"
|
||||
|
||||
namespace mobject {
|
||||
namespace session {
|
||||
|
||||
|
||||
|
||||
/** TODO??? */
|
||||
Scope::Scope (PlacementMO const& constitutingPlacement)
|
||||
: anchor_(constitutingPlacement)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
ScopeLocator::ScopeLocator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}} // namespace mobject::session
|
||||
70
src/proc/mobject/session/scope.hpp
Normal file
70
src/proc/mobject/session/scope.hpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
SCOPE.hpp - 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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MOBJECT_SESSION_SCOPE_H
|
||||
#define MOBJECT_SESSION_SCOPE_H
|
||||
|
||||
//#include "proc/mobject/mobject.hpp"
|
||||
#include "proc/mobject/placement.hpp"
|
||||
#include "proc/mobject/placement-ref.hpp"
|
||||
#include "lib/singleton.hpp"
|
||||
|
||||
//#include <vector>
|
||||
//#include <string>
|
||||
|
||||
//using std::vector;
|
||||
//using std::string;
|
||||
|
||||
namespace mobject {
|
||||
namespace session {
|
||||
|
||||
|
||||
class ScopeLocator;
|
||||
|
||||
|
||||
/**
|
||||
* TODO type comment
|
||||
*/
|
||||
class Scope
|
||||
{
|
||||
RefPlacement anchor_;
|
||||
|
||||
public:
|
||||
Scope (PlacementMO const& constitutingPlacement);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ScopeLocator
|
||||
{
|
||||
|
||||
public:
|
||||
ScopeLocator();
|
||||
|
||||
};
|
||||
///////////////////////////TODO currently just fleshing the API
|
||||
|
||||
|
||||
}} // namespace mobject::session
|
||||
#endif
|
||||
|
|
@ -55,6 +55,10 @@ PLANNED "PlacementRef_test" PlacementRef_test <<END
|
|||
END
|
||||
|
||||
|
||||
PLANNED "Placement search scope" PlacementScope_test <<END
|
||||
END
|
||||
|
||||
|
||||
PLANNED "Path of nested scopes" ScopePath_test <<END
|
||||
END
|
||||
|
||||
|
|
|
|||
81
tests/components/proc/mobject/placement-scope-test.cpp
Normal file
81
tests/components/proc/mobject/placement-scope-test.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
PlacementScope(Test) - accessing and navigating placement scope
|
||||
|
||||
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 "lib/test/run.hpp"
|
||||
#include "proc/mobject/session/test-scopes.hpp"
|
||||
//#include "lib/lumitime.hpp"
|
||||
//#include "proc/mobject/placement-ref.hpp"
|
||||
//#include "proc/mobject/placement-index.hpp"
|
||||
//#include "proc/mobject/test-dummy-mobject.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
//using util::isSameObject;
|
||||
//using lumiera::Time;
|
||||
//using std::string;
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
|
||||
|
||||
namespace mobject {
|
||||
namespace session {
|
||||
namespace test {
|
||||
|
||||
// using namespace mobject::test;
|
||||
// typedef TestPlacement<TestSubMO21> PSub;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* @test basic behaviour of the nested placement search scopes.
|
||||
* Using a pseudo-session (actually just a PlacementIndex), this test
|
||||
* creates some nested scopes and then...
|
||||
* - discovers the scope of a placement
|
||||
* - finds the parent scope
|
||||
* - enumerates a scope path up to root
|
||||
*
|
||||
* @see mobject::Placement
|
||||
* @see mobject::session::ScopePath
|
||||
* @see mobject::session::QueryFocus
|
||||
*/
|
||||
class PlacementScope_test : public Test
|
||||
{
|
||||
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
// Prepare an (test)Index backing the PlacementRefs
|
||||
PIdx index = build_testScopes();
|
||||
|
||||
UNIMPLEMENTED ("function test of placement scope interface");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** Register this test class... */
|
||||
LAUNCHER (PlacementScope_test, "function session");
|
||||
|
||||
|
||||
}}} // namespace mobject::session::test
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
#include "lib/test/run.hpp"
|
||||
//#include "lib/lumitime.hpp"
|
||||
//#include "proc/mobject/placement-ref.hpp"
|
||||
#include "proc/mobject/session/test-scopes.hpp"
|
||||
#include "proc/mobject/placement-index.hpp"
|
||||
#include "proc/mobject/test-dummy-mobject.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
|
|
@ -42,8 +42,6 @@ namespace mobject {
|
|||
namespace session {
|
||||
namespace test {
|
||||
|
||||
using namespace mobject::test;
|
||||
typedef TestPlacement<TestSubMO21> PSub;
|
||||
|
||||
|
||||
/**********************************************************************************
|
||||
|
|
@ -61,28 +59,14 @@ namespace test {
|
|||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
PSub p1(*new TestSubMO21);
|
||||
PSub p2(*new TestSubMO21);
|
||||
PSub p3(*new TestSubMO21);
|
||||
PSub p4(*new TestSubMO21);
|
||||
PSub p5(*new TestSubMO21);
|
||||
|
||||
// Prepare an (test)Index backing the PlacementRefs
|
||||
typedef shared_ptr<PlacementIndex> PIdx;
|
||||
PIdx index (PlacementIndex::create());
|
||||
PMO& root = index->getRoot();
|
||||
reset_PlacementIndex(index);
|
||||
|
||||
index->insert (p1, root);
|
||||
index->insert (p2, p1 );
|
||||
index->insert (p3, p2 );
|
||||
index->insert (p4, p3 );
|
||||
index->insert (p5, p4 );
|
||||
PIdx index = build_testScopes();
|
||||
// PMO& root = index->getRoot();
|
||||
|
||||
UNIMPLEMENTED ("unit test to cover query focus management");
|
||||
|
||||
//?? ASSERT (0 == index->size());
|
||||
reset_PlacementIndex();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
|
||||
#include "lib/test/run.hpp"
|
||||
#include "proc/mobject/session/test-scopes.hpp"
|
||||
//#include "lib/lumitime.hpp"
|
||||
//#include "proc/mobject/placement-ref.hpp"
|
||||
//#include "proc/mobject/placement-index.hpp"
|
||||
|
|
@ -60,6 +61,9 @@ namespace test {
|
|||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
// Prepare an (test)Index backing the PlacementRefs
|
||||
PIdx index = build_testScopes();
|
||||
|
||||
UNIMPLEMENTED ("unit test regarding placement scope handling");
|
||||
}
|
||||
|
||||
|
|
|
|||
84
tests/components/proc/mobject/session/test-scopes.cpp
Normal file
84
tests/components/proc/mobject/session/test-scopes.cpp
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
TEST-SCOPES.cpp - builds a test PlacementIndex containing dummy Placements as nested scopes
|
||||
|
||||
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/test-scopes.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
//using util::isSameObject;
|
||||
//using lumiera::Time;
|
||||
//using std::string;
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
|
||||
|
||||
namespace mobject {
|
||||
namespace session {
|
||||
namespace test {
|
||||
|
||||
|
||||
namespace { // deleter function to clean up Test fixture
|
||||
void
|
||||
remove_testIndex (PlacementIndex* testIdx)
|
||||
{
|
||||
REQUIRE (testIdx);
|
||||
testIdx->clear();
|
||||
ASSERT (0 == testIdx->size());
|
||||
reset_PlacementIndex(); // restore default Index from Session
|
||||
|
||||
delete testIdx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @note when this object goes out of scope, the activation of this
|
||||
* test PlacementIndex will be cleared automatically, and the
|
||||
* default Index within the session will be re-activated.
|
||||
*/
|
||||
PIdx
|
||||
build_testScopes()
|
||||
{
|
||||
PSub p1(*new TestSubMO21);
|
||||
PSub p2(*new TestSubMO21);
|
||||
PSub p3(*new TestSubMO21);
|
||||
PSub p4(*new TestSubMO21);
|
||||
PSub p5(*new TestSubMO21);
|
||||
|
||||
// Prepare an (test)Index backing the PlacementRefs
|
||||
PIdx index (PlacementIndex::create().get(), &remove_testIndex); // taking ownership
|
||||
reset_PlacementIndex(index);
|
||||
PMO& root = index->getRoot();
|
||||
|
||||
index->insert (p1, root);
|
||||
index->insert (p2, p1 );
|
||||
index->insert (p3, p2 );
|
||||
index->insert (p4, p3 );
|
||||
index->insert (p5, p4 );
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
}}} // namespace mobject::session::test
|
||||
72
tests/components/proc/mobject/session/test-scopes.hpp
Normal file
72
tests/components/proc/mobject/session/test-scopes.hpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
TEST-SCOPES.hpp - builds a test PlacementIndex containing dummy Placements as nested scopes
|
||||
|
||||
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_TEST_TEST_SCOPES_H
|
||||
#define MOBJECT_SESSION_TEST_TEST_SCOPES_H
|
||||
|
||||
|
||||
//#include "lib/lumitime.hpp"
|
||||
//#include "proc/mobject/placement-ref.hpp"
|
||||
#include "proc/mobject/session/test-scopes.hpp"
|
||||
#include "proc/mobject/test-dummy-mobject.hpp"
|
||||
#include "proc/mobject/placement-index.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
#include <tr1/memory>
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
//using util::isSameObject;
|
||||
//using lumiera::Time;
|
||||
//using std::string;
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
|
||||
|
||||
namespace mobject {
|
||||
namespace session {
|
||||
namespace test {
|
||||
|
||||
using std::tr1::shared_ptr;
|
||||
|
||||
using namespace mobject::test;
|
||||
typedef TestPlacement<TestSubMO21> PSub;
|
||||
typedef shared_ptr<PlacementIndex> PIdx;
|
||||
|
||||
|
||||
|
||||
/** helper for tests: create a pseudo-session (actually just a PlacementIndex),
|
||||
* which contains some nested placement scopes.
|
||||
* @return new PlacementIndex, which has already been activated to be used
|
||||
* by all Placements from now on. This activation will be cleared
|
||||
* automatically, when this object goes out of scope.
|
||||
*
|
||||
* @see mobject::PlacementIndex
|
||||
* @see session::SessManagerImpl::getCurrentIndex()
|
||||
* @see mobject::reset_PlacementIndex
|
||||
*/
|
||||
PIdx build_testScopes();
|
||||
|
||||
|
||||
}}} // namespace mobject::session::test
|
||||
#endif
|
||||
Loading…
Reference in a new issue