WIP draft for a generic hash based and typed id, similar to asset::ID

This commit is contained in:
Fischlurch 2009-05-21 20:26:44 +02:00
parent 35ebe966b5
commit 87362a4b0d
2 changed files with 46 additions and 0 deletions

View file

@ -45,6 +45,45 @@ namespace mobject {
// using std::tr1::shared_ptr;
/** @todo WIP a generic hash-index, maybe also usable for assets */
struct LuidH
{
long dummy_;
};
template<typename T>
struct HaID;
struct TestA
{
LuidH id_;
HaID<TestA> const& getID() const;
};
struct TestBA : TestA {};
struct TestBB : TestA {};
template<>
struct HaID<TestA> : LuidH
{
HaID () : LuidH () {}
HaID (TestA const& ref) : LuidH (ref.getID()) {}
};
template<typename T>
struct HaID : HaID<TestA>
{
HaID () : HaID<TestA> () {}
HaID (T const& ref) : HaID<TestA> (ref) {}
};
inline
HaID<TestA> const&
TestA::getID() const
{
return *(static_cast<const HaID<TestA>*> (&id_));
}
/**
*/

View file

@ -27,6 +27,7 @@
//#include "proc/mobject/session/edl.hpp"
//#include "proc/mobject/session/testclip.hpp"
#include "proc/mobject/placement.hpp"
#include "proc/mobject/placement-ref.hpp"
//#include "proc/mobject/explicitplacement.hpp"
//#include "lib/util.hpp"
@ -46,6 +47,12 @@ namespace test {
using asset::VIDEO;
/** @todo WIP a generic hash-index, maybe also usable for assets */
HaID<TestBB> hahaBB1;
TestBA bab;
HaID<TestBA> hahaBA1 (bab);
///////////////////////////////TODO (Experimentation)
/***************************************************************************