DefaultRemapDir Class Reference

#include <ref.h>

Class Description

Implements a default version of a RemapDir.

See also
CloneRefHierarchy(), ReferenceTarget::Clone() Instances of this class are used as the default argument to the ReferenceTarget::Clone method. When the boolean use_A_WORK2_flag is set to TRUE, the remap directory will set this flag on all entries in the remap directory, and will assume that any object that DOESN'T have this flag set is not in the remap directory. This avoids the search through the directory and speeds up things greatly. When using this feature, you must first clear A_WORK2 on all of the objects being cloned. DS: 3/17/00. When the instance is deleted, the Backpatch() method is automatically called if backpatch operations were added but never performed.
Precondition
First clear the A_WORK2 flag on all objects being cloned.
Postcondition
Flag is set on all entries in remap directory.
Parameters
use_A_WORK2_flag- used to set this flag on all entries in the remap directory.
+ Inheritance diagram for DefaultRemapDir:

Public Member Functions

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

Constructor & Destructor Documentation

CoreExport DefaultRemapDir ( BOOL  use_A_WORK2_flag = FALSE)

Member Function Documentation

RefTargetHandle FindMapping ( RefTargetHandle  from)
virtual

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

Implements RemapDir.

void AddEntry ( RefTargetHandle  hfrom,
RefTargetHandle  hto 
)
virtual

Registers a mapping of original object to clone.

Implements RemapDir.

void PatchPointer ( RefTargetHandle patchThis,
RefTargetHandle  oldTarg 
)
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.

Implements RemapDir.

void Backpatch ( )
virtual

Runs back patch procedures and PostPatchProcs.

Implements RemapDir.

bool BackpatchPending ( )
virtual

Used internally.

Implements RemapDir.

void Clear ( )
virtual

Used internally.

Implements RemapDir.

void ClearBackpatch ( )
virtual

Used internally.

Implements RemapDir.

void DeleteThis ( )
virtual

Used internally.

Implements RemapDir.

void AddPostPatchProc ( PostPatchProc proc,
bool  toDelete 
)
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.

Implements RemapDir.