BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
abstract base class for accessing objects indexed in various ways. More...
#include <index.hpp>
Public Member Functions | |
virtual | ~index ()=default |
virtual uint8_t | object_space_id () const =0 |
virtual uint8_t | object_type_id () const =0 |
virtual object_id_type | get_next_id () const =0 |
virtual void | use_next_id ()=0 |
virtual void | set_next_id (object_id_type id)=0 |
virtual const object & | load (const std::vector< char > &data)=0 |
virtual const object & | insert (object &&obj)=0 |
virtual const object & | create (const std::function< void(object &)> &constructor)=0 |
virtual void | open (const fc::path &db)=0 |
virtual void | save (const fc::path &db)=0 |
virtual const object * | find (object_id_type id) const =0 |
const object & | get (object_id_type id) const |
virtual void | modify (const object &obj, const std::function< void(object &)> &)=0 |
virtual void | remove (const object &obj)=0 |
template<typename Object , typename Lambda > | |
void | modify (const Object &obj, const Lambda &l) |
virtual void | inspect_all_objects (std::function< void(const object &)> inspector) const =0 |
virtual void | add_observer (const std::shared_ptr< index_observer > &)=0 |
virtual void | object_from_variant (const fc::variant &var, object &obj, uint32_t max_depth) const =0 |
virtual void | object_default (object &obj) const =0 |
abstract base class for accessing objects indexed in various ways.
All indexes assume that there exists an object ID space that will grow forever in a seqential manner. These IDs are used to identify the index, type, and instance of the object.
Items in an index can only be modified via a call to modify and all references to objects outside of that callback are const references.
Most implementations will probably be some form of boost::multi_index_container which means that they can covnert a reference to an object to an iterator. When at all possible save a pointer/reference to your objects rather than constantly looking them up by ID.
|
virtualdefault |
|
pure virtual |
Implemented in graphene::db::primary_index< graphene::db::generic_index >.
|
pure virtual |
Builds a new object and assigns it the next available ID and then initializes it with constructor and lastly inserts it into the index.
Implemented in graphene::db::primary_index< graphene::db::generic_index >, graphene::db::generic_index< ObjectType, MultiIndexType >, graphene::db::generic_index< T, boost::multi_index_container< T, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > > > > >, and graphene::db::simple_index< T >.
|
pure virtual |
Implemented in graphene::db::primary_index< graphene::db::generic_index >, graphene::db::generic_index< ObjectType, MultiIndexType >, graphene::db::generic_index< T, boost::multi_index_container< T, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > > > > >, and graphene::db::simple_index< T >.
|
inline |
|
pure virtual |
Polymorphically insert by moving an object into the index. this should throw if the object is already in the database.
Implemented in graphene::db::primary_index< graphene::db::generic_index >, graphene::db::simple_index< T >, graphene::db::generic_index< ObjectType, MultiIndexType >, and graphene::db::generic_index< T, boost::multi_index_container< T, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > > > > >.
|
pure virtual |
|
pure virtual |
Implemented in graphene::db::primary_index< graphene::db::generic_index >.
|
inline |
When forming your lambda to modify obj, it is natural to have Object& be the signature, but that is not compatible with the type erasue required by the virtual method. This method provides a helper to wrap the lambda in a form compatible with the virtual modify call.
|
pure virtual |
Implemented in graphene::db::simple_index< T >, graphene::db::primary_index< graphene::db::generic_index >, graphene::db::generic_index< ObjectType, MultiIndexType >, and graphene::db::generic_index< T, boost::multi_index_container< T, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > > > > >.
|
pure virtual |
Implemented in graphene::db::primary_index< graphene::db::generic_index >.
|
pure virtual |
Implemented in graphene::db::primary_index< graphene::db::generic_index >.
|
pure virtual |
|
pure virtual |
|
pure virtual |
Opens the index loading objects from a file
Implemented in graphene::db::primary_index< graphene::db::generic_index >.
|
pure virtual |
Implemented in graphene::db::primary_index< graphene::db::generic_index >, graphene::db::generic_index< ObjectType, MultiIndexType >, graphene::db::generic_index< T, boost::multi_index_container< T, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > > > > >, and graphene::db::simple_index< T >.
|
pure virtual |
Implemented in graphene::db::primary_index< graphene::db::generic_index >.
|
pure virtual |
Implemented in graphene::db::primary_index< graphene::db::generic_index >.
|
pure virtual |
Implemented in graphene::db::primary_index< graphene::db::generic_index >.