Blender V5.0
blender::GenericKey Class Referenceabstract

#include <BLI_generic_key.hh>

Inherited by blender::GenericStringKey, blender::memory_cache::LoadFileKey, and blender::memory_cache::tests::GenericIntKey.

Public Member Functions

virtual ~GenericKey ()=default
virtual uint64_t hash () const =0
virtual bool equal_to (const GenericKey &other) const =0
virtual std::unique_ptr< GenericKeyto_storable () const =0

Friends

bool operator== (const GenericKey &a, const GenericKey &b)
bool operator!= (const GenericKey &a, const GenericKey &b)

Detailed Description

A GenericKey allows different kinds of keys to be used in the same data-structure like a Set or Map.

Typically, the key is stored as std::reference_wrapper<const GenericKey> in the data-structure. That implies that one has to make sure that the key is not destructed while it's still in use.

Definition at line 26 of file BLI_generic_key.hh.

Constructor & Destructor Documentation

◆ ~GenericKey()

virtual blender::GenericKey::~GenericKey ( )
virtualdefault

Member Function Documentation

◆ equal_to()

virtual bool blender::GenericKey::equal_to ( const GenericKey & other) const
pure virtual

Check if the other key is equal to this one. Usually that involves a dynamic_cast to check if it has the same type.

Implemented in blender::GenericStringKey, blender::memory_cache::LoadFileKey, and blender::memory_cache::tests::GenericIntKey.

Referenced by operator==.

◆ hash()

virtual uint64_t blender::GenericKey::hash ( ) const
pure virtual

The hash function has to be implemented by the non-abstract subclass.

Implemented in blender::GenericStringKey, blender::memory_cache::LoadFileKey, and blender::memory_cache::tests::GenericIntKey.

◆ to_storable()

virtual std::unique_ptr< GenericKey > blender::GenericKey::to_storable ( ) const
pure virtual

For efficiency, it can be good to not always allocate the key if it's just used for lookup. This method allows the key to be converted into a heap-allocated version that can be stored safely if necessary.

Implemented in blender::GenericStringKey, blender::memory_cache::LoadFileKey, and blender::memory_cache::tests::GenericIntKey.

Referenced by blender::memory_cache::get_base(), and blender::memory_cache::get_loaded_base().

◆ operator!=

bool operator!= ( const GenericKey & a,
const GenericKey & b )
friend

Definition at line 54 of file BLI_generic_key.hh.

References b.

◆ operator==

bool operator== ( const GenericKey & a,
const GenericKey & b )
friend

Definition at line 46 of file BLI_generic_key.hh.

References b, BLI_assert, and equal_to().


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