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

A simple index uses a vector<unique_ptr<T>> to store data. More...

#include <simple_index.hpp>

Inheritance diagram for graphene::db::simple_index< T >:
graphene::db::index

Classes

class  const_iterator
 

Public Types

using object_type = T
 

Public Member Functions

virtual const objectcreate (const std::function< void(object &)> &constructor) override
 
virtual void modify (const object &obj, const std::function< void(object &)> &modify_callback) override
 
virtual const objectinsert (object &&obj) override
 
virtual void remove (const object &obj) override
 
virtual const objectfind (object_id_type id) const override
 
virtual void inspect_all_objects (std::function< void(const object &)> inspector) const override
 
const_iterator begin () const
 
const_iterator end () const
 
size_t size () 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 T>
class graphene::db::simple_index< T >

A simple index uses a vector<unique_ptr<T>> to store data.

This index is preferred in situations where the data will never be removed from main memory and when access by ID is the only kind of access that is necessary.

Definition at line 38 of file simple_index.hpp.

Member Typedef Documentation

◆ object_type

template<typename T >
using graphene::db::simple_index< T >::object_type = T

Definition at line 41 of file simple_index.hpp.

Member Function Documentation

◆ begin()

template<typename T >
const_iterator graphene::db::simple_index< T >::begin ( ) const
inline

Definition at line 134 of file simple_index.hpp.

◆ create()

template<typename T >
virtual const object& graphene::db::simple_index< T >::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.

Definition at line 43 of file simple_index.hpp.

◆ end()

template<typename T >
const_iterator graphene::db::simple_index< T >::end ( ) const
inline

Definition at line 135 of file simple_index.hpp.

◆ find()

template<typename T >
virtual const object* graphene::db::simple_index< T >::find ( object_id_type  id) const
inlineoverridevirtual
Returns
the object with id or nullptr if not found

Implements graphene::db::index.

Definition at line 81 of file simple_index.hpp.

◆ insert()

template<typename T >
virtual const object& graphene::db::simple_index< T >::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.

Definition at line 62 of file simple_index.hpp.

◆ inspect_all_objects()

template<typename T >
virtual void graphene::db::simple_index< T >::inspect_all_objects ( std::function< void(const object &)>  inspector) const
inlineoverridevirtual

Implements graphene::db::index.

Definition at line 91 of file simple_index.hpp.

◆ modify()

template<typename T >
virtual void graphene::db::simple_index< T >::modify ( const object obj,
const std::function< void(object &)> &  modify_callback 
)
inlineoverridevirtual

Implements graphene::db::index.

Definition at line 56 of file simple_index.hpp.

◆ remove()

template<typename T >
virtual void graphene::db::simple_index< T >::remove ( const object obj)
inlineoverridevirtual

Implements graphene::db::index.

Definition at line 72 of file simple_index.hpp.

◆ size()

template<typename T >
size_t graphene::db::simple_index< T >::size ( ) const
inline

Definition at line 137 of file simple_index.hpp.


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