From 1fb327f6a0470a548def002506cf5fe5ea7be43d Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Thu, 24 Sep 2015 12:55:10 -0400 Subject: [PATCH] object_id.hpp: Add is() and as() template functions to object_id_type --- libraries/db/include/graphene/db/object_id.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libraries/db/include/graphene/db/object_id.hpp b/libraries/db/include/graphene/db/object_id.hpp index eb784f90..00a616e6 100644 --- a/libraries/db/include/graphene/db/object_id.hpp +++ b/libraries/db/include/graphene/db/object_id.hpp @@ -67,6 +67,19 @@ namespace graphene { namespace db { return a.number < b.number; } + template< typename T > + bool is() const + { + return (number >> 48) == ((T::space_id << 8) | (T::type_id)); + } + + template< typename T > + T as() const + { + FC_ASSERT( is() ); + return T( *this ); + } + uint64_t number; };