Skip to content

Commit

Permalink
static space_type for abstract_object (optional)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimfred committed Sep 7, 2019
1 parent 21872e9 commit c214135
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions libraries/db/include/graphene/db/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ namespace graphene { namespace db {
}
virtual variant to_variant()const { return variant( static_cast<const DerivedClass&>(*this), MAX_NESTING ); }
virtual vector<char> pack()const { return fc::raw::pack( static_cast<const DerivedClass&>(*this) ); }

static constexpr uint16_t space_type()
{
return (uint16_t)DerivedClass::space_id << 8 | DerivedClass::type_id;
}
};

typedef flat_map<uint8_t, object_id_type> annotation_map;
Expand Down
16 changes: 8 additions & 8 deletions libraries/plugins/es_objects/es_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
{
switch( value.space_type() )
{
case( proposal_object::space_id << 8 | proposal_object::type_id ):
case( proposal_object::space_type() ):
{
if( _es_objects_proposals ) {
auto obj = db.find_object(value);
Expand All @@ -165,7 +165,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
}
break;
}
case( account_object::space_id << 8 | account_object::type_id ):
case( account_object::space_type() ):
{
if( _es_objects_accounts ) {
auto obj = db.find_object(value);
Expand All @@ -179,7 +179,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
}
break;
}
case( asset_object::space_id << 8 | asset_object::type_id ):
case( asset_object::space_type() ):
{
if( _es_objects_assets ) {
auto obj = db.find_object(value);
Expand All @@ -193,7 +193,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
}
break;
}
case( account_balance_object::space_id << 8 | account_balance_object::type_id ):
case( account_balance_object::space_type() ):
{
if( _es_objects_balances ) {
auto obj = db.find_object(value);
Expand All @@ -207,7 +207,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
}
break;
}
case( limit_order_object::space_id << 8 | limit_order_object::type_id ):
case( limit_order_object::space_type() ):
{
if( _es_objects_limit_orders ) {
auto obj = db.find_object(value);
Expand All @@ -221,7 +221,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
}
break;
}
case( asset_bitasset_data_object::space_id << 8 | asset_bitasset_data_object::type_id ):
case( asset_bitasset_data_object::space_type() ):
{
if( _es_objects_asset_bitasset ) {
auto obj = db.find_object(value);
Expand All @@ -235,7 +235,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
}
break;
}
case( voting_statistics_object::space_id << 8 | voting_statistics_object::type_id ):
case( voting_statistics_object::space_type() ):
{
if( _es_objects_voting_statistics ) {
auto obj = db.find_object(value);
Expand All @@ -250,7 +250,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
}
break;
}
case( voteable_statistics_object::space_id << 8 | voteable_statistics_object::type_id ):
case( voteable_statistics_object::space_type() ):
{
if( _es_objects_voteable_statistics ) {
auto obj = db.find_object(value);
Expand Down

0 comments on commit c214135

Please sign in to comment.