3ds Max C++ API Reference
Loading...
Searching...
No Matches
RemapDir Class Referenceabstract

For remapping references during a Clone. More...

#include <ref.h>

+ Inheritance diagram for RemapDir:

Public Member Functions

Clone Methods
virtual RefTargetHandle FindMapping (RefTargetHandle from)=0
 Returns a pointer to an item's clone if it was cloned or NULL otherwise.
 
virtual RefTargetHandle CloneRef (RefTargetHandle oldTarg)
 Creates a clone of a reference target only if it hasn't been cloned already.
 
virtual void PatchPointer (RefTargetHandle *patchThis, RefTargetHandle oldTarg)=0
 This method is used to back patch the pointer for cloned items.
 
virtual void AddPostPatchProc (PostPatchProc *proc, bool toDelete)=0
 Adds a Procedure that is called after cloning and back patching.
 
Internal methods
virtual void AddEntry (RefTargetHandle hfrom, RefTargetHandle hto)=0
 Registers a mapping of original object to clone.
 
virtual void Backpatch ()=0
 Runs back patch procedures and PostPatchProcs.
 
virtual bool BackpatchPending ()=0
 Used internally.
 
virtual void Clear ()=0
 Used internally.
 
virtual void ClearBackpatch ()=0
 Used internally.
 
virtual void DeleteThis ()=0
 Used internally.
 
virtual ~RemapDir ()
 Used internally.
 

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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator.
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator.
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary.
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary.
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc.
 

Detailed Description

For remapping references during a Clone.

See also
CloneRefHierarchy(), ReferenceTarget::Clone() This class is used for remapping references during a Clone. It is used when cloning items that are instanced so that the plugin can maintain the same instance relationship within the clone. All methods of this class are implemented by the system.

Constructor & Destructor Documentation

◆ ~RemapDir()

virtual ~RemapDir ( )
inlinevirtual

Used internally.

958{}

Member Function Documentation

◆ FindMapping()

virtual RefTargetHandle FindMapping ( RefTargetHandle  from)
pure virtual

Returns a pointer to an item's clone if it was cloned or NULL otherwise.

Parameters
from- This is the item to see if cloned.
Returns
A pointer to the clone of the item, NULL if not cloned

Implemented in DefaultRemapDir.

◆ CloneRef()

virtual RefTargetHandle CloneRef ( RefTargetHandle  oldTarg)
virtual

Creates a clone of a reference target only if it hasn't been cloned already.

This method will clone the item if was not already cloned, register the item and its clone with the RemapDir, and return a pointer to the clone. If the item was previously cloned, a pointer to the clone is returned. In the ReferenceTarget::Clone() procedure when an item is cloning itself it should clone all its references. Instead of calling Clone() on its references it should instead call this method passing it the item to clone. This ensures that all objects are cloned at most one time. For example:

class MyDerivedPlugin
: public MyBasePlugin
{
const int MY_REFERENCE = 1;
ReferenceTarget* Clone(RemapDir& remap)
{
ReferenceTarget* result = new MyDerivedPlugin();
BaseClone(this, result, remap);
return result;
}
void BaseClone(ReferenceTarget* from, ReferenceTarget* to, RemapDir& remap)
{
if (!to || !from || from == to)
return;
MyBasePlugin::BaseClone(from, to, remap);
to->ReplaceReference(MY_REFERENCE, remap->CloneRef(from->GetReference(MY_REFERENCE)));
}
};
virtual CoreExport RefTargetHandle GetReference(int i)
Returns the 'i-th' reference.
CoreExport RefResult ReplaceReference(int which, RefTargetHandle newtarg, BOOL delOld=TRUE)
Used when cloning reference makers.
A scene entity that is being owned and listened to by other scene entities.
Definition: ref.h:1849
For remapping references during a Clone.
Definition: ref.h:830
virtual RefTargetHandle CloneRef(RefTargetHandle oldTarg)
Creates a clone of a reference target only if it hasn't been cloned already.
Parameters
oldTarg- This is the item that is to be cloned.
Returns
A pointer to the clone of the item.

◆ PatchPointer()

virtual void PatchPointer ( RefTargetHandle patchThis,
RefTargetHandle  oldTarg 
)
pure virtual

This method is used to back patch the pointer for cloned items.

If oldTarg has already been cloned, then the RefTargetHandle variable pointed to by patchThis is set to the pointer of the clone. If oldTarg has not been cloned, a back patch procedure is registered that is run after all cloning is completed but before the PostPatchProcs are run. The back patch procedure checks to see if oldTarg has been cloned, and if so the the RefTargetHandle variable pointed to by patchThis is set to the pointer of the clone. If oldTarg has not been cloned, the RefTargetHandle variable pointed to by patchThis is set to oldTarg. Because there may be a delayed write to the RefTargetHandle variable, this variable should not be a stack variable. Note that this method is primarily used when an object being cloned holds a raw pointer to a ReferenceTarget (i.e., it does not hold a reference to the ReferenceTarget). In general, this is not safe due to the potential for a dangling pointer when that ReferenceTarget is deleted. It is better to use a SingleRefMaker or a SingleWeakRefMaker member variable to hold the pointer as it will hold a reference to the ReferenceTarget and properly NULL the pointer when/if the ReferenceTarget is deleted.

See also
SingleRefMaker, SingleWeakRefMaker
Parameters
patchThis- The RefTargetHandle variable to be set.
oldTarg- The original target.

Implemented in DefaultRemapDir.

◆ AddPostPatchProc()

virtual void AddPostPatchProc ( PostPatchProc proc,
bool  toDelete 
)
pure virtual

Adds a Procedure that is called after cloning and back patching.

This method is used for adding a PostPatchProc whose procedure method is called after the reference hierarchy has been cloned and any back patching has occurred. These will be called in the order that they are registered. The PostPatchProc procs are called from the RemapDirImp::Backpatch(). More information can be found at the RefTargMonitorRefMaker::Proc method. See NodeMonitor::Clone for an example.

Parameters
proc- Points to the callback object.
toDelete- If true, the callback object is deleted when the RemapDir is deleted.

Implemented in DefaultRemapDir.

◆ AddEntry()

virtual void AddEntry ( RefTargetHandle  hfrom,
RefTargetHandle  hto 
)
pure virtual

Registers a mapping of original object to clone.

Implemented in DefaultRemapDir.

◆ Backpatch()

virtual void Backpatch ( )
pure virtual

Runs back patch procedures and PostPatchProcs.

Implemented in DefaultRemapDir.

◆ BackpatchPending()

virtual bool BackpatchPending ( )
pure virtual

Used internally.

Implemented in DefaultRemapDir.

◆ Clear()

virtual void Clear ( )
pure virtual

Used internally.

Implemented in DefaultRemapDir.

◆ ClearBackpatch()

virtual void ClearBackpatch ( )
pure virtual

Used internally.

Implemented in DefaultRemapDir.

◆ DeleteThis()

virtual void DeleteThis ( )
pure virtual

Used internally.

Implemented in DefaultRemapDir.