Kagome
Polkadot Runtime Engine in C++17
objects_cache.hpp File Reference
#include <memory>
#include <mutex>
#include <type_traits>
#include <vector>
Include dependency graph for objects_cache.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tools::containers::ObjsCacheDefAlloc< Type >
 
struct  tools::containers::ObjectsCache< T, Alloc >
 
struct  tools::containers::CacheUnit< T >
 
struct  tools::containers::ObjectsCacheManager< T, ARGS >
 
struct  tools::containers::ObjectsCacheManager< T >
 

Namespaces

 tools::containers
 

Macros

#define KAGOME_CACHE_UNIT(type)   tools::containers::CacheUnit<type>
 
#define KAGOME_DECLARE_CACHE(prefix, ...)
 
#define KAGOME_UNIQUE_TYPE_CACHE(prefix, type)   prefix##_UCachedType<type>
 
#define KAGOME_DEFINE_CACHE(prefix)   prefix##_cache_type prefix##_cache;
 
#define KAGOME_EXTRACT_SHARED_CACHE(prefix, type)   prefix##_get_shared_from_cache<type>()
 
#define KAGOME_EXTRACT_UNIQUE_CACHE(prefix, type)   prefix##_get_unique_from_cache<type>()
 
#define KAGOME_EXTRACT_RAW_CACHE(prefix, type)   prefix##_get_from_cache<type>()
 
#define KAGOME_INSERT_RAW_CACHE(prefix, obj)   prefix##_set_to_cache(obj)
 

Class Documentation

struct tools::containers::CacheUnit

template<typename T>
struct tools::containers::CacheUnit< T >

Cache item entry.

Template Parameters
Tis the type of the objects to be contained in cache.

Definition at line 119 of file objects_cache.hpp.

Collaboration diagram for tools::containers::CacheUnit< T >:
Class Members
typedef typename
remove_pointer< typename decay
< T >::type >::type
Type

Macro Definition Documentation

#define KAGOME_CACHE_UNIT (   type)    tools::containers::CacheUnit<type>

Definition at line 137 of file objects_cache.hpp.

#define KAGOME_DECLARE_CACHE (   prefix,
  ... 
)
Value:
using prefix##_cache_type = \
tools::containers::ObjectsCacheManager<__VA_ARGS__>; \
template <typename T> \
using prefix##_UCachedType = std::unique_ptr<T, void (*)(T *const)>; \
extern prefix##_cache_type prefix##_cache; \
template <typename T> \
inline T *prefix##_get_from_cache() { \
return static_cast<tools::containers::ObjectsCache<T> *>(&prefix##_cache) \
->getCachedObject(); \
} \
template <typename T> \
inline void prefix##_set_to_cache(T *const ptr) { \
static_cast<tools::containers::ObjectsCache<T> *>(&prefix##_cache) \
->setCachedObject(ptr); \
} \
template <typename T> \
inline std::shared_ptr<T> prefix##_get_shared_from_cache() { \
return static_cast<tools::containers::ObjectsCache<T> *>(&prefix##_cache) \
->getSharedCachedObject(); \
} \
template <typename T> \
inline prefix##_UCachedType<T> prefix##_get_unique_from_cache() { \
return prefix##_UCachedType<T>(prefix##_get_from_cache<T>(), \
&prefix##_set_to_cache<T>); \
}

Set of macro to define/declare object container and to define functions to communicate with it.

Definition at line 145 of file objects_cache.hpp.

#define KAGOME_DEFINE_CACHE (   prefix)    prefix##_cache_type prefix##_cache;

Definition at line 178 of file objects_cache.hpp.

#define KAGOME_EXTRACT_RAW_CACHE (   prefix,
  type 
)    prefix##_get_from_cache<type>()

Definition at line 192 of file objects_cache.hpp.

#define KAGOME_EXTRACT_SHARED_CACHE (   prefix,
  type 
)    prefix##_get_shared_from_cache<type>()

Definition at line 182 of file objects_cache.hpp.

#define KAGOME_EXTRACT_UNIQUE_CACHE (   prefix,
  type 
)    prefix##_get_unique_from_cache<type>()

Definition at line 187 of file objects_cache.hpp.

#define KAGOME_INSERT_RAW_CACHE (   prefix,
  obj 
)    prefix##_set_to_cache(obj)

Definition at line 196 of file objects_cache.hpp.

#define KAGOME_UNIQUE_TYPE_CACHE (   prefix,
  type 
)    prefix##_UCachedType<type>

Definition at line 174 of file objects_cache.hpp.