object_database.hpp: Implement template methods for downcasting objects
This commit is contained in:
parent
e9acc40a7d
commit
a2b9bc6d27
1 changed files with 13 additions and 0 deletions
|
|
@ -87,6 +87,19 @@ namespace graphene { namespace db {
|
||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static const T& cast( const object& obj )
|
||||||
|
{
|
||||||
|
assert( nullptr != dynamic_cast<const T*>(&obj) );
|
||||||
|
return static_cast<const T&>(obj);
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
static T& cast( object& obj )
|
||||||
|
{
|
||||||
|
assert( nullptr != dynamic_cast<T*>(&obj) );
|
||||||
|
return static_cast<T&>(obj);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
const T& get( object_id_type id )const
|
const T& get( object_id_type id )const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue