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

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

Public Types

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

Public Member Functions

 HdInstanceRegistry (const HdInstanceRegistry &other)
 Copy constructor. More...
 
InstanceType GetInstance (typename InstanceType::KeyType const &key)
 Returns a shared instance for given key. More...
 
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. More...
 
size_t GarbageCollect (int recycleCount=0)
 Removes unreferenced entries and returns the count of remaining entries. More...
 
const_iterator begin () const
 
const_iterator end () 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

typedef InstanceType::Dictionary::const_iterator const_iterator

Returns a const iterator being/end of dictionary.

Mainly used for resource auditing.

Definition at line 177 of file instanceRegistry.h.

Constructor & Destructor Documentation

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

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

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

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

Returns a shared instance for given key.

Definition at line 200 of file instanceRegistry.h.


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