object_database.hpp: Implement template methods for downcasting objects

This commit is contained in:
theoreticalbts 2015-06-15 20:38:51 -04:00
parent e9acc40a7d
commit a2b9bc6d27

View file

@ -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>
const T& get( object_id_type id )const
{