3ds Max C++ API Reference
TranslatorKey Class Referenceabstract

Unique identifier for a translator in the scene's translation graph. More...

#include <TranslatorKey.h>

+ Inheritance diagram for TranslatorKey:

Public Member Functions

 TranslatorKey (const size_t hash)
 Initializes the translator key with a given hash value. More...
 
virtual ~TranslatorKey ()
 
virtual bool operator== (const TranslatorKey &rhs) const =0
 Returns whether the given key is identical to this one. More...
 
size_t get_hash () const
 Returns the hash value passed to the constructor. More...
 
virtual std::unique_ptr< const TranslatorKeyCreateClone () const =0
 Allocates and initialized a brand new copy of this key. More...
 
virtual std::unique_ptr< TranslatorAllocateNewTranslator (TranslatorGraphNode &translator_graph_node, const IRenderSessionContext &render_session_context, const TimeValue initial_time) const =0
 Factory method for the type of translator represented by this key. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

Unique identifier for a translator in the scene's translation graph.

The TranslatorKey plays three roles:

  • It unique identifies a single translator in the tranlsation scene graph. It does this through operator==(), with the help of a hash value.
  • It encapsulates the inputs of a translator - everything that a translator needs to produce its outputs. This may be an INode*, a Mtl*, a set of boolean flags, an arbitrary data structure.
  • It is the factory for the type of translator it represents.

This class should rarely be implemented directly by the plugin developer. Instead, consider using one of the built-in implementations of translator keys, which greatly simplify the task:

Constructor & Destructor Documentation

◆ TranslatorKey()

TranslatorKey ( const size_t  hash)
inline

Initializes the translator key with a given hash value.

The has value is used to efficiently search the lookup table that contains all of the scene's translators. As is standard with hash values, it doesn't have to be unique - but should be well-distributed within the space covered by size_t. Two keys that are deemed to be equal by operator==() must have identical hash values.

19  : m_hash(hash)
20 {
21 
22 }

◆ ~TranslatorKey()

virtual ~TranslatorKey ( )
inlinevirtual
63 {}

Member Function Documentation

◆ operator==()

virtual bool operator== ( const TranslatorKey rhs) const
pure virtual

Returns whether the given key is identical to this one.

The comparison should typically consider, both, the set of values stored in the key, and the type of the key, such that two keys that store identical values (e.g. the same INode*) but which create different types of translators (e.g. Instance versus InstanceAttributes) would be deemed to be different. Such comparison will typically be performed using a dynamic_cast.

Implemented in GenericTranslatorKey_Struct< TranslatorType, StructType, Hash, TranslatorAllocator >, GenericTranslatorKey_SingleReference< TranslatorType, ReferencedType, TranslatorAllocator >, GenericTranslatorKey_SinglePointer< TranslatorType, PointerType, TranslatorAllocator >, and GenericTranslatorKey_Empty< TranslatorType, TranslatorAllocator >.

◆ get_hash()

size_t get_hash ( ) const
inline

Returns the hash value passed to the constructor.

25 {
26  return m_hash;
27 }

◆ CreateClone()

virtual std::unique_ptr<const TranslatorKey> CreateClone ( ) const
pure virtual

Allocates and initialized a brand new copy of this key.

For efficiency, keys will normally be allocated on the stack - such that Translator::AcquireChildTranslator() will be called with a temporary key, avoiding an unnecessary memory allocation. But if a new translator needs to be created, then the system also needs to store a copy of the key. For this purpose, it creates a clone of the key using this method.

Implemented in GenericTranslatorKey_Struct< TranslatorType, StructType, Hash, TranslatorAllocator >, GenericTranslatorKey_SingleReference< TranslatorType, ReferencedType, TranslatorAllocator >, GenericTranslatorKey_SinglePointer< TranslatorType, PointerType, TranslatorAllocator >, and GenericTranslatorKey_Empty< TranslatorType, TranslatorAllocator >.

◆ AllocateNewTranslator()

virtual std::unique_ptr<Translator> AllocateNewTranslator ( TranslatorGraphNode &  translator_graph_node,
const IRenderSessionContext render_session_context,
const TimeValue  initial_time 
) const
pure virtual

Factory method for the type of translator represented by this key.

Whenever a new translator needs to be created for a given key, that key is responsible for allocating the new instance of that type of translator.

Parameters
translator_graph_nodeThe parameter which is to be passed to the constructor of class Translator.
render_session_contextThe render session context within which the translator is being created.
initial_timeThe time at which the translator will initially be translated. This may be used, by the method, to evalate scene elements and thus judge exactly what type of translator needs to be allocated (if a single key type maps to multiple types of translators).
Returns
A new instance of a translator which uses this key as input.

Implemented in GenericTranslatorKey_Struct< TranslatorType, StructType, Hash, TranslatorAllocator >, GenericTranslatorKey_SingleReference< TranslatorType, ReferencedType, TranslatorAllocator >, GenericTranslatorKey_SinglePointer< TranslatorType, PointerType, TranslatorAllocator >, and GenericTranslatorKey_Empty< TranslatorType, TranslatorAllocator >.