lumiera_/src/lib/ha-id.hpp

126 lines
2.3 KiB
C++

/*
HA-ID.hpp - generic hash based and hierarchically typed ID
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.
*/
/** @file ha-id.hpp
**
** @see HaID_test
** @see Placement usage example
**
*/
#ifndef LIB_HA_ID_H
#define LIB_HA_ID_H
//#include "pre.hpp"
//#include "proc/mobject/session/locatingpin.hpp"
//#include "proc/asset/pipe.hpp"
//#include <tr1/memory>
namespace lib {
// using std::tr1::shared_ptr;
/** @todo WIP a generic hash-index, maybe also usable for assets */
struct LuidH
{
long dummy_;
};
template<typename T, class BA>
struct HaID;
template<class BA>
struct HaIndexed
{
LuidH id_;
HaID<BA,BA> const& getID() const;
};
template<class BA>
struct HaID<BA,BA> : LuidH
{
HaID () : LuidH () {}
HaID (BA const& ref) : LuidH (ref.getID()) {}
};
template<typename T, class BA>
struct HaID : HaID<BA,BA>
{
HaID () : HaID<BA,BA> () {}
HaID (T const& ref) : HaID<BA,BA> (ref) {}
};
template<class BA>
inline HaID<BA,BA> const&
HaIndexed<BA>::getID() const
{
return *(static_cast<const HaID<BA,BA>*> (&id_));
}
struct Base
{
int ii_;
};
struct TestA : Base, HaIndexed<TestA>
{
};
struct TestBA : TestA {};
struct TestBB : TestA {};
/**
*/
class PlacementRef
{
public:
/**
*
*/
class ID
{
};
template<class MO>
class IDp : public ID
{
};
};
} // namespace lib
#endif