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

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

Public Types

typedef
INSTANCE::Dictionary::const_iterator 
const_iterator
 Returns a const iterator being/end of dictionary. More...
 

Public Member Functions

 HdInstanceRegistry (const HdInstanceRegistry &other)
 Copy constructor. More...
 
std::unique_lock< std::mutex > GetInstance (typename INSTANCE::KeyType const &key, INSTANCE *instance)
 Returns a shared instance for given key as a pair of (key, value). More...
 
std::unique_lock< std::mutex > FindInstance (typename INSTANCE::KeyType const &key, INSTANCE *instance, bool *found)
 Returns a shared instance for a given key as a pair of (key, value) only if the key exists in the dictionary. More...
 
size_t GarbageCollect ()
 Remove entries which has unreferenced key and returns the count of remaining entries. More...
 
const_iterator begin () const
 
const_iterator end () const
 
void Invalidate ()
 

Detailed Description

template<typename INSTANCE>
class HdInstanceRegistry< INSTANCE >

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 113 of file instanceRegistry.h.

Member Typedef Documentation

typedef INSTANCE::Dictionary::const_iterator const_iterator

Returns a const iterator being/end of dictionary.

Mainly used for resource auditing.

Definition at line 140 of file instanceRegistry.h.

Constructor & Destructor Documentation

HdInstanceRegistry ( const HdInstanceRegistry< INSTANCE > &  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 119 of file instanceRegistry.h.

Member Function Documentation

std::unique_lock< std::mutex > FindInstance ( typename INSTANCE::KeyType const &  key,
INSTANCE *  instance,
bool *  found 
)

Returns a shared instance for a given key as a pair of (key, value) only if the key exists in the dictionary.

Definition at line 191 of file instanceRegistry.h.

size_t GarbageCollect ( )

Remove entries which has unreferenced key and returns the count of remaining entries.

Definition at line 214 of file instanceRegistry.h.

std::unique_lock< std::mutex > GetInstance ( typename INSTANCE::KeyType const &  key,
INSTANCE *  instance 
)

Returns a shared instance for given key as a pair of (key, value).

Definition at line 164 of file instanceRegistry.h.


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