RemapDir Class Reference

RemapDir Class Referenceabstract

#include <ref.h>

Class 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.
+ Inheritance diagram for RemapDir:

Public Member Functions

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

Constructor & Destructor Documentation

virtual ~RemapDir ( )
inlinevirtual

Used internally.

916 {}

Member Function Documentation

virtual RefTargetHandle FindMapping ( RefTargetHandle  from)
pure virtual

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

Implemented in DefaultRemapDir.

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)));
}
};
Parameters
oldTarg- This is the item that is to be cloned.
Returns
A pointer to the clone of the item.
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.

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.

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

Registers a mapping of original object to clone.

Implemented in DefaultRemapDir.

virtual void Backpatch ( )
pure virtual

Runs back patch procedures and PostPatchProcs.

Implemented in DefaultRemapDir.

virtual bool BackpatchPending ( )
pure virtual

Used internally.

Implemented in DefaultRemapDir.

virtual void Clear ( )
pure virtual

Used internally.

Implemented in DefaultRemapDir.

virtual void ClearBackpatch ( )
pure virtual

Used internally.

Implemented in DefaultRemapDir.

virtual void DeleteThis ( )
pure virtual

Used internally.

Implemented in DefaultRemapDir.