HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HdInstanceRegistry< VALUE > Class Template Reference

#include <instanceRegistry.h>

Public Types

typedef HdInstance< VALUE > InstanceType
 
typedef
InstanceType::Dictionary::const_iterator 
const_iterator
 

Public Member Functions

 HdInstanceRegistry ()=default
 
 HdInstanceRegistry (const HdInstanceRegistry &other)
 
InstanceType GetInstance (typename InstanceType::KeyType const &key)
 Returns a shared instance for given key. More...
 
InstanceType FindInstance (typename InstanceType::KeyType const &key, bool *found)
 
size_t GarbageCollect (int recycleCount=0)
 
template<typename Callback >
size_t GarbageCollect (Callback &&callback, int recycleCount=0)
 
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

template<typename VALUE>
typedef InstanceType::Dictionary::const_iterator HdInstanceRegistry< VALUE >::const_iterator

Returns a const iterator being/end of dictionary. Mainly used for resource auditing.

Definition at line 186 of file instanceRegistry.h.

template<typename VALUE>
typedef HdInstance<VALUE> HdInstanceRegistry< VALUE >::InstanceType

Definition at line 148 of file instanceRegistry.h.

Constructor & Destructor Documentation

template<typename VALUE>
HdInstanceRegistry< VALUE >::HdInstanceRegistry ( )
default
template<typename VALUE>
HdInstanceRegistry< VALUE >::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

template<typename VALUE>
const_iterator HdInstanceRegistry< VALUE >::begin ( void  ) const
inline

Definition at line 187 of file instanceRegistry.h.

template<typename VALUE>
const_iterator HdInstanceRegistry< VALUE >::end ( void  ) const
inline

Definition at line 188 of file instanceRegistry.h.

template<typename VALUE>
HdInstance< VALUE > HdInstanceRegistry< 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.

template<typename VALUE >
size_t HdInstanceRegistry< VALUE >::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.

template<typename VALUE >
template<typename Callback >
size_t HdInstanceRegistry< VALUE >::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.

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

Returns a shared instance for given key.

Definition at line 211 of file instanceRegistry.h.

template<typename VALUE >
void HdInstanceRegistry< VALUE >::Invalidate ( )

Definition at line 295 of file instanceRegistry.h.

template<typename VALUE>
size_t HdInstanceRegistry< VALUE >::size ( void  ) const
inline

Definition at line 190 of file instanceRegistry.h.


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