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

This class is used as a pointer to the shared instance in HdInstanceRegistry. More...

Public Types

typedef KEY KeyType
 
typedef VALUE ValueType
 
typedef
tbb::concurrent_unordered_map
< KeyType, ValueType > 
Dictionary
 

Public Member Functions

 HdInstance ()
 Constructor. More...
 
void Create (KeyType const &key, ValueType const &value, Dictionary *parent, bool isFirstInstance)
 Initalize the members of HdInstance. More...
 
KeyType const & GetKey () const
 Returns the key. More...
 
ValueType const & GetValue () const
 Returns the value. More...
 
void SetValue (ValueType const &value)
 Update the value in dictionary indexed by the key. More...
 
bool IsFirstInstance () const
 Returns true if the value has not been initialized. More...
 

Detailed Description

template<typename KEY, typename VALUE>
class HdInstance< KEY, VALUE >

This class is used as a pointer to the shared instance in HdInstanceRegistry.

KEY has to be hashable index type and VALUE is shared_ptr. In most use cases, the client computes a hash key which represents large bulky data (like topology, primvars) and registers it into HdInstanceRegistry. If the key has already been registered, the registry returns HdInstance and the client can use GetValue() without setting/computing actual bulky data. If it doesn't exist, IsFirstInstance() returns true for the first instance and the client needs to populate an appropriate data into through the instance by SetValue().

Definition at line 56 of file instanceRegistry.h.

Constructor & Destructor Documentation

HdInstance ( )
inline

Constructor.

Definition at line 64 of file instanceRegistry.h.

Member Function Documentation

void Create ( KeyType const &  key,
ValueType const &  value,
Dictionary *  parent,
bool  isFirstInstance 
)
inline

Initalize the members of HdInstance.

Definition at line 67 of file instanceRegistry.h.

KeyType const& GetKey ( ) const
inline

Returns the key.

Definition at line 79 of file instanceRegistry.h.

ValueType const& GetValue ( ) const
inline

Returns the value.

Definition at line 82 of file instanceRegistry.h.

bool IsFirstInstance ( ) const
inline

Returns true if the value has not been initialized.

Definition at line 91 of file instanceRegistry.h.

void SetValue ( ValueType const &  value)
inline

Update the value in dictionary indexed by the key.

Definition at line 85 of file instanceRegistry.h.


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