preliminary placement index impl started.

Basically I need this simple framework to be able to write tests,
which enables me to flesh out the API, which in turn is a
prerequisite for defining the PlacementRef
This commit is contained in:
Fischlurch 2009-05-20 03:36:12 +02:00
parent cab776847d
commit cc66f2b0d0
6 changed files with 157 additions and 35 deletions

View file

@ -93,6 +93,7 @@ liblumiprocmobject_la_SOURCES = \
$(liblumiprocmobject_la_srcdir)/mobject.cpp \
$(liblumiprocmobject_la_srcdir)/parameter.cpp \
$(liblumiprocmobject_la_srcdir)/paramprovider.cpp \
$(liblumiprocmobject_la_srcdir)/placement-index.cpp \
$(liblumiprocmobject_la_srcdir)/placement.cpp

View file

@ -44,8 +44,7 @@
namespace asset
{
namespace asset {
class Clip;
class Media;

View file

@ -0,0 +1,81 @@
/*
PlacementIndex - tracking individual Placements and their relations
Copyright (C) Lumiera.org
2008, 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.
* *****************************************************/
/** @file placement-index.cpp
**
** simple hash based implementation. Proof-of-concept
** and for fleshing out the API
**
** @todo change PlacementIndex into an interface and create a separated implementation class
** @see PlacementRef
** @see PlacementIndex_test
**
*/
#include "proc/mobject/placement-index.hpp"
//#include <boost/format.hpp>
//using boost::str;
namespace mobject {
class PlacementIndex::Table
{
public:
Table ()
{ }
size_t
size() const
{
UNIMPLEMENTED ("PlacementIndex datastructure");
return 0;
}
};
/** */
size_t
PlacementIndex::size() const
{
return pTab_->size() - 1;
}
/** @internal factory function for creating a placement index for tests.
*/
shared_ptr<PlacementIndex>
createPlacementIndex ()
{
return shared_ptr<PlacementIndex> (new PlacementIndex());
}
} // namespace mobject

View file

@ -36,15 +36,18 @@
//#include "pre.hpp"
//#include "proc/mobject/session/locatingpin.hpp"
//#include "proc/asset/pipe.hpp"
#include "proc/mobject/placement.hpp"
#include "proc/mobject/placement-ref.hpp"
//#include <tr1/memory>
#include <tr1/memory>
#include <boost/scoped_ptr.hpp>
#include <vector>
namespace mobject {
// using std::tr1::shared_ptr;
using std::tr1::shared_ptr;
using boost::scoped_ptr;
using std::vector;
@ -53,37 +56,49 @@ namespace mobject {
*/
class PlacementIndex
{
public:
typedef Placement<MObject> PlacementMO;
typedef PlacementRef PRef;
typedef PRef::ID ID;
PlacementMO& find (ID) const;
template<class MO>
Placement<MO>& find (PRef::IDp<MO>) const;
PlacementMO& getScope (PlacementMO&) const;
PlacementMO& getScope (ID) const;
vector<PRef> getReferrers (ID) const;
/** diagnostic: number of indexed entries */
size_t size() const;
/* == mutating operations == */
ID insert (PlacementMO& newObj, PlacementMO& targetScope);
bool remove (PlacementMO&);
bool remove (ID);
class Table;
scoped_ptr<Table> pTab_;
public:
typedef Placement<MObject> PlacementMO;
typedef PlacementRef PRef;
typedef PRef::ID ID;
PlacementMO& find (ID) const;
template<class MO>
Placement<MO>& find (PRef::IDp<MO>) const;
PlacementMO& getScope (PlacementMO&) const;
PlacementMO& getScope (ID) const;
vector<PRef> getReferrers (ID) const;
/** retrieve the logical root scope */
PlacementMO& getRoot() const;
/** diagnostic: number of indexed entries */
size_t size() const;
bool contains (PlacementMO&) const;
/* == mutating operations == */
ID insert (PlacementMO& newObj, PlacementMO& targetScope);
bool remove (PlacementMO&);
bool remove (ID);
};
////////////////TODO currently just fleshing out the API; probably have to split off an impl.class
////////////////TODO currently just fleshing out the API; probably have to split off an impl.class; but for now a PImpl is sufficient...
/** preliminary helper for creating a placement index (instance).
* @todo integrate this into the session and provide an extra factory for tests
*/
shared_ptr<PlacementIndex>
createPlacementIndex() ;
} // namespace mobject

View file

@ -50,6 +50,7 @@ namespace mobject {
*/
class PlacementRef
{
public:
/**
*
*/

View file

@ -25,8 +25,9 @@
//#include "proc/asset/media.hpp"
//#include "proc/mobject/session.hpp"
//#include "proc/mobject/session/edl.hpp"
//#include "proc/mobject/session/testclip.hpp"
#include "proc/mobject/session/testclip.hpp"
#include "proc/mobject/placement.hpp"
#include "proc/mobject/placement-index.hpp"
//#include "proc/mobject/explicitplacement.hpp"
//#include "lib/util.hpp"
@ -41,10 +42,10 @@ using std::string;
namespace mobject {
namespace session {
namespace test {
using asset::VIDEO;
using session::test::TestClip;
@ -58,12 +59,36 @@ namespace test {
*/
class PlacementIndex_test : public Test
{
typedef shared_ptr<PlacementIndex> PIdx;
virtual void
run (Arg)
{
PIdx index (createPlacementIndex());
ASSERT (index);
/////////////////////////////////TODO
}
checkSimpleInsert (index);
}
void
checkSimpleInsert (PIdx index)
{
PMO clip = TestClip::create();
// PMO& root = index->getRoot();
ASSERT (0 == index->size());
// ASSERT (!index->contains (clip));
// index->insert (clip, root);
ASSERT (1 == index->size());
// ASSERT ( index->contains (clip));
// index->remove(clip);
ASSERT (0 == index->size());
// ASSERT (!index->contains (clip));
// ASSERT ( index->contains (root));
}
};
@ -71,4 +96,4 @@ namespace test {
LAUNCHER (PlacementIndex_test, "unit session");
}}} // namespace mobject::session::test
}} // namespace mobject::test