BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
Public Types | Public Member Functions | List of all members
graphene::db::generic_index< ObjectType, MultiIndexType > Class Template Reference

#include <generic_index.hpp>

Inheritance diagram for graphene::db::generic_index< ObjectType, MultiIndexType >:
graphene::db::index graphene::db::primary_index< graphene::db::generic_index >

Public Types

using index_type = MultiIndexType
 
using object_type = ObjectType
 

Public Member Functions

const objectinsert (object &&obj) override
 
const objectcreate (const std::function< void(object &)> &constructor) override
 
void modify (const object &obj, const std::function< void(object &)> &m) override
 
void remove (const object &obj) override
 
const objectfind (object_id_type id) const override
 
void inspect_all_objects (std::function< void(const object &)> inspector) const override
 
const index_typeindices () const
 
- Public Member Functions inherited from graphene::db::index
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 objectload (const std::vector< char > &data)=0
 
virtual void open (const fc::path &db)=0
 
virtual void save (const fc::path &db)=0
 
const objectget (object_id_type id) const
 
template<typename Object , typename Lambda >
void modify (const Object &obj, const Lambda &l)
 
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
 

Detailed Description

template<typename ObjectType, typename MultiIndexType>
class graphene::db::generic_index< ObjectType, MultiIndexType >

Almost all objects can be tracked and managed via a boost::multi_index container that uses an unordered_unique key on the object ID. This template class adapts the generic index interface to work with arbitrary boost multi_index containers on the same type.

Definition at line 43 of file generic_index.hpp.

Member Typedef Documentation

◆ index_type

template<typename ObjectType , typename MultiIndexType >
using graphene::db::generic_index< ObjectType, MultiIndexType >::index_type = MultiIndexType

Definition at line 46 of file generic_index.hpp.

◆ object_type

template<typename ObjectType , typename MultiIndexType >
using graphene::db::generic_index< ObjectType, MultiIndexType >::object_type = ObjectType

Definition at line 47 of file generic_index.hpp.

Member Function Documentation

◆ create()

template<typename ObjectType , typename MultiIndexType >
const object& graphene::db::generic_index< ObjectType, MultiIndexType >::create ( const std::function< void(object &)> &  constructor)
inlineoverridevirtual

Builds a new object and assigns it the next available ID and then initializes it with constructor and lastly inserts it into the index.

Implements graphene::db::index.

Reimplemented in graphene::db::primary_index< graphene::db::generic_index >.

Definition at line 58 of file generic_index.hpp.

◆ find()

template<typename ObjectType , typename MultiIndexType >
const object* graphene::db::generic_index< ObjectType, MultiIndexType >::find ( object_id_type  id) const
inlineoverridevirtual
Returns
the object with id or nullptr if not found

Implements graphene::db::index.

Reimplemented in graphene::db::primary_index< graphene::db::generic_index >.

Definition at line 98 of file generic_index.hpp.

◆ indices()

template<typename ObjectType , typename MultiIndexType >
const index_type& graphene::db::generic_index< ObjectType, MultiIndexType >::indices ( ) const
inline

Definition at line 115 of file generic_index.hpp.

◆ insert()

template<typename ObjectType , typename MultiIndexType >
const object& graphene::db::generic_index< ObjectType, MultiIndexType >::insert ( object &&  obj)
inlineoverridevirtual

Polymorphically insert by moving an object into the index. this should throw if the object is already in the database.

Implements graphene::db::index.

Reimplemented in graphene::db::primary_index< graphene::db::generic_index >.

Definition at line 49 of file generic_index.hpp.

◆ inspect_all_objects()

template<typename ObjectType , typename MultiIndexType >
void graphene::db::generic_index< ObjectType, MultiIndexType >::inspect_all_objects ( std::function< void(const object &)>  inspector) const
inlineoverridevirtual

Implements graphene::db::index.

Definition at line 107 of file generic_index.hpp.

◆ modify()

template<typename ObjectType , typename MultiIndexType >
void graphene::db::generic_index< ObjectType, MultiIndexType >::modify ( const object obj,
const std::function< void(object &)> &  m 
)
inlineoverridevirtual

◆ remove()

template<typename ObjectType , typename MultiIndexType >
void graphene::db::generic_index< ObjectType, MultiIndexType >::remove ( const object obj)
inlineoverridevirtual

The documentation for this class was generated from the following file: