Skip to content

Commit c214135

Browse files
committed
static space_type for abstract_object (optional)
1 parent 21872e9 commit c214135

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

libraries/db/include/graphene/db/object.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ namespace graphene { namespace db {
101101
}
102102
virtual variant to_variant()const { return variant( static_cast<const DerivedClass&>(*this), MAX_NESTING ); }
103103
virtual vector<char> pack()const { return fc::raw::pack( static_cast<const DerivedClass&>(*this) ); }
104+
105+
static constexpr uint16_t space_type()
106+
{
107+
return (uint16_t)DerivedClass::space_id << 8 | DerivedClass::type_id;
108+
}
104109
};
105110

106111
typedef flat_map<uint8_t, object_id_type> annotation_map;

libraries/plugins/es_objects/es_objects.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
151151
{
152152
switch( value.space_type() )
153153
{
154-
case( proposal_object::space_id << 8 | proposal_object::type_id ):
154+
case( proposal_object::space_type() ):
155155
{
156156
if( _es_objects_proposals ) {
157157
auto obj = db.find_object(value);
@@ -165,7 +165,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
165165
}
166166
break;
167167
}
168-
case( account_object::space_id << 8 | account_object::type_id ):
168+
case( account_object::space_type() ):
169169
{
170170
if( _es_objects_accounts ) {
171171
auto obj = db.find_object(value);
@@ -179,7 +179,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
179179
}
180180
break;
181181
}
182-
case( asset_object::space_id << 8 | asset_object::type_id ):
182+
case( asset_object::space_type() ):
183183
{
184184
if( _es_objects_assets ) {
185185
auto obj = db.find_object(value);
@@ -193,7 +193,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
193193
}
194194
break;
195195
}
196-
case( account_balance_object::space_id << 8 | account_balance_object::type_id ):
196+
case( account_balance_object::space_type() ):
197197
{
198198
if( _es_objects_balances ) {
199199
auto obj = db.find_object(value);
@@ -207,7 +207,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
207207
}
208208
break;
209209
}
210-
case( limit_order_object::space_id << 8 | limit_order_object::type_id ):
210+
case( limit_order_object::space_type() ):
211211
{
212212
if( _es_objects_limit_orders ) {
213213
auto obj = db.find_object(value);
@@ -221,7 +221,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
221221
}
222222
break;
223223
}
224-
case( asset_bitasset_data_object::space_id << 8 | asset_bitasset_data_object::type_id ):
224+
case( asset_bitasset_data_object::space_type() ):
225225
{
226226
if( _es_objects_asset_bitasset ) {
227227
auto obj = db.find_object(value);
@@ -235,7 +235,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
235235
}
236236
break;
237237
}
238-
case( voting_statistics_object::space_id << 8 | voting_statistics_object::type_id ):
238+
case( voting_statistics_object::space_type() ):
239239
{
240240
if( _es_objects_voting_statistics ) {
241241
auto obj = db.find_object(value);
@@ -250,7 +250,7 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
250250
}
251251
break;
252252
}
253-
case( voteable_statistics_object::space_id << 8 | voteable_statistics_object::type_id ):
253+
case( voteable_statistics_object::space_type() ):
254254
{
255255
if( _es_objects_voteable_statistics ) {
256256
auto obj = db.find_object(value);

0 commit comments

Comments
 (0)