Loading...
Searching...
No Matches
HdInstanceRegistry< VALUE > Class Template Reference

HdInstanceRegistry is a dictionary container of HdInstance. More...

#include <instanceRegistry.h>

Public Types

typedef HdInstance< VALUE > InstanceType
 
typedef InstanceType::Dictionary::const_iterator const_iterator
 Returns a const iterator being/end of dictionary.
 

Public Member Functions

 HdInstanceRegistry (const HdInstanceRegistry &other)
 Copy constructor.
 
InstanceType GetInstance (typename InstanceType::KeyType const &key)
 Returns a shared instance for given key.
 
InstanceType FindInstance (typename InstanceType::KeyType const &key, bool *found)
 Returns a shared instance for a given key only if the key exists in the dictionary.
 
size_t GarbageCollect (int recycleCount=0)
 Removes unreferenced entries and returns the count of remaining entries.
 
template<typename Callback >
size_t GarbageCollect (Callback &&callback, int recycleCount=0)
 Removes unreferenced entries and returns the count of remaining entries.
 
const_iterator begin () const
 
const_iterator end () const
 
size_t size () const
 
void Invalidate ()
 

Detailed Description

template<typename VALUE>
class HdInstanceRegistry< VALUE >

HdInstanceRegistry is a dictionary container of HdInstance.

This class is almost just a dictionary from key to value. For cleaning unused entries, it provides GarbageCollect() API. It sweeps all entries in the dictionary and erase unreferenced entries. When HdInstance::ValueType is shared_ptr, it is regarded as unreferenced if the shared_ptr is unique (use_count==1). Note that Key is not involved to determine the lifetime of entries.

Definition at line 146 of file instanceRegistry.h.

Member Typedef Documentation

◆ const_iterator

typedef InstanceType::Dictionary::const_iterator const_iterator

Returns a const iterator being/end of dictionary.

Mainly used for resource auditing.

Definition at line 186 of file instanceRegistry.h.

◆ InstanceType

typedef HdInstance<VALUE> InstanceType

Definition at line 148 of file instanceRegistry.h.

Constructor & Destructor Documentation

◆ HdInstanceRegistry()

HdInstanceRegistry ( const HdInstanceRegistry< VALUE > &  other)
inline

Copy constructor.

Need as HdInstanceRegistry is placed in a map and mutex is not copy constructable, so can't use default

Definition at line 154 of file instanceRegistry.h.

Member Function Documentation

◆ begin()

const_iterator begin ( ) const
inline

Definition at line 187 of file instanceRegistry.h.

◆ end()

const_iterator end ( ) const
inline

Definition at line 188 of file instanceRegistry.h.

◆ FindInstance()

HdInstance< VALUE > FindInstance ( typename InstanceType::KeyType const &  key,
bool *  found 
)

Returns a shared instance for a given key only if the key exists in the dictionary.

Definition at line 234 of file instanceRegistry.h.

◆ GarbageCollect() [1/2]

size_t GarbageCollect ( Callback &&  callback,
int  recycleCount = 0 
)

Removes unreferenced entries and returns the count of remaining entries.

If an entry is to be removed, callback function "callback" will be called on the entry before removal. When recycleCount is greater than zero, unreferenced entries will not be removed until GarbageCollect() is called that many more times, i.e. allowing unreferenced entries to be recycled if they are needed again.

Definition at line 266 of file instanceRegistry.h.

◆ GarbageCollect() [2/2]

size_t GarbageCollect ( int  recycleCount = 0)

Removes unreferenced entries and returns the count of remaining entries.

When recycleCount is greater than zero, unreferenced entries will not be removed until GarbageCollect() is called that many more times, i.e. allowing unreferenced entries to be recycled if they are needed again.

Definition at line 257 of file instanceRegistry.h.

◆ GetInstance()

HdInstance< VALUE > GetInstance ( typename InstanceType::KeyType const &  key)

Returns a shared instance for given key.

Definition at line 211 of file instanceRegistry.h.

◆ Invalidate()

void Invalidate

Definition at line 295 of file instanceRegistry.h.

◆ size()

size_t size ( ) const
inline

Definition at line 190 of file instanceRegistry.h.


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