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

#include <instanceRegistry.h>

Classes

struct  ValueHolder
 

Public Types

typedef uint64_t KeyType
 
typedef VALUE ValueType
 
typedef KeyType ID
 
typedef
tbb::concurrent_unordered_map
< KeyType, ValueHolder
Dictionary
 
typedef std::mutex RegistryMutex
 
typedef std::unique_lock
< RegistryMutex
RegistryLock
 

Public Member Functions

 HdInstance ()=delete
 
 HdInstance (KeyType const &key, ValueType const &value, RegistryLock &&registryLock, Dictionary *container)
 
 HdInstance (KeyType const &key)
 
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 VALUE>
class HdInstance< VALUE >

This class is used as an interface to a shared instance in HdInstanceRegistry.

KeyType is a 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 VALUE into the instance by SetValue().

In order to support concurrent access to HdInstanceRegistry, this class holds a lock to a mutex in HdInstanceRegistry. This lock will be held until the instance of this interface class is destroyed.

Definition at line 60 of file instanceRegistry.h.

Member Typedef Documentation

template<typename VALUE>
typedef tbb::concurrent_unordered_map<KeyType, ValueHolder> HdInstance< VALUE >::Dictionary

Definition at line 79 of file instanceRegistry.h.

template<typename VALUE>
typedef KeyType HdInstance< VALUE >::ID

Definition at line 65 of file instanceRegistry.h.

template<typename VALUE>
typedef uint64_t HdInstance< VALUE >::KeyType

Definition at line 62 of file instanceRegistry.h.

template<typename VALUE>
typedef std::unique_lock<RegistryMutex> HdInstance< VALUE >::RegistryLock

Definition at line 82 of file instanceRegistry.h.

template<typename VALUE>
typedef std::mutex HdInstance< VALUE >::RegistryMutex

Definition at line 81 of file instanceRegistry.h.

template<typename VALUE>
typedef VALUE HdInstance< VALUE >::ValueType

Definition at line 63 of file instanceRegistry.h.

Constructor & Destructor Documentation

template<typename VALUE>
HdInstance< VALUE >::HdInstance ( )
delete
template<typename VALUE>
HdInstance< VALUE >::HdInstance ( KeyType const &  key,
ValueType const &  value,
RegistryLock &&  registryLock,
Dictionary container 
)
inlineexplicit

Construct an instance holding a registry lock, representing a value held in a registry container.

Definition at line 88 of file instanceRegistry.h.

template<typename VALUE>
HdInstance< VALUE >::HdInstance ( KeyType const &  key)
inlineexplicit

Construct an instance with no lock or registry container. This is used to present a consistent interface to clients in cases where shared resource registration is disabled.

Definition at line 102 of file instanceRegistry.h.

Member Function Documentation

template<typename VALUE>
KeyType const& HdInstance< VALUE >::GetKey ( ) const
inline

Returns the key.

Definition at line 111 of file instanceRegistry.h.

template<typename VALUE>
ValueType const& HdInstance< VALUE >::GetValue ( ) const
inline

Returns the value.

Definition at line 114 of file instanceRegistry.h.

template<typename VALUE>
bool HdInstance< VALUE >::IsFirstInstance ( ) const
inline

Returns true if the value has not been initialized.

Definition at line 123 of file instanceRegistry.h.

template<typename VALUE>
void HdInstance< VALUE >::SetValue ( ValueType const &  value)
inline

Update the value in dictionary indexed by the key.

Definition at line 117 of file instanceRegistry.h.


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