Public Member Functions | Protected Member Functions | Protected Attributes

SingleRefMaker Class Reference

This reference page is linked to from the following overview topics: Reference System Best Practices.


Search for all occurrences

Detailed Description

Reference Maker to single entity.

See also:
Class ReferenceMaker, Class IRefTargContainer This class encapsulates the management of one single reference. It is entirely implemented by 3ds Max. Plugins can use SingleRefMaker as is, or derive from it when they need to respond to reference messages other than REFMSG_TARGET_DELETED.
Examples:
See Standard Material shaders switch maxsdk\samples\materials\stdmtl2.cpp for sample usage.
See also maxsdk.

#include <ref.h>

Inheritance diagram for SingleRefMaker:
Inheritance graph
[legend]

List of all members.

Public Member Functions

CoreExport  SingleRefMaker ()
  Constructor.
CoreExport  ~SingleRefMaker ()
  Destructor.
CoreExport void  SetRef (RefTargetHandle rt)
  Set the Reference.
CoreExport RefTargetHandle  GetRef () const
  Get the Reference.
CoreExport RefResult  NotifyRefChanged (Interval changeInt, RefTargetHandle hTarget, PartID &partID, RefMessage message)
  By default handles REFMSG_TARGET_DELETED message only.
CoreExport void  DeleteThis ()
  Deletes an instance of this class.
CoreExport SClass_ID  SuperClassID ()
  Retrieves a constant representing the type of the plugin.
CoreExport int  NumRefs ()
  Returns the total number of references this ReferenceMaker can hold.
CoreExport RefTargetHandle  GetReference (int i)
  Returns the 'i-th' reference.
CoreExport BOOL  CanTransferReference (int i)
  Tells whether this reference can be transfered.

Protected Member Functions

virtual CoreExport void  SetReference (int i, RefTargetHandle rtarg)
  Stores a ReferenceTarget as its 'i-th' reference`.

Protected Attributes

RefTargetHandle  rtarget
  Handle to the single reference.

Constructor & Destructor Documentation

CoreExport SingleRefMaker ( )

Constructor.

CoreExport ~SingleRefMaker ( )

Destructor.

Suspended from Undo system


Member Function Documentation

CoreExport void SetRef ( RefTargetHandle  rt )

Set the Reference.

Suspended from Undo system

CoreExport RefTargetHandle GetRef ( ) const

Get the Reference.

CoreExport RefResult NotifyRefChanged ( Interval  changeInt,
RefTargetHandle  hTarget,
PartID partID,
RefMessage  message 
) [virtual]

By default handles REFMSG_TARGET_DELETED message only.

This function should be overridden by plugins that need to respond to reference messages. If this is done, it is still recommended to call the original implementation

            NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message )
            {
                switch(message) { 
                    // Handle our messages
                }
                // Handles REFMSG_TARGET_DELETED
                return SingleRefMaker::NotifyRefChanged(changeInt, hTarget, partID, message);
            }

See ReferenceMaker::NotifyRefChanged for complete documentation

Implements ReferenceMaker.

Reimplemented in SingleRefMakerPatchNode, SingleRefMakerPatchMtl, SingleWeakRefMaker, SingleRefMakerSplineNode, and SingleRefMakerSplineMtl.

CoreExport void DeleteThis ( ) [virtual]

Deletes an instance of this class.

3ds Max calls this method when it needs to delete a plugin object (an instance of a class derived from Animatable). Similarly, plugins that need to delete instances of an Animatable or a class directly derived from it via an Animatable pointer, should call this method instead of calling directly operator delete. Following these rules will ensure that the same memory manager is used to allocate and deallocate the object. The default implementation of this method deletes the object. Plugin instances that never need to be deleted from the heap can overwrite this method to do nothing.

Note:
See the method ClassDesc::Create() for details on how Max allocates plugin objects.
See ReferenceMaker::DeleteMe() and ReferenceTarget::MaybeAutoDelete() for information on how plugin instances are deleted by the system.
Remarks:
See Memory Allocation.

See also:
Plugin DLL Functions, Class ClassDesc.

Reimplemented from Animatable.

Reimplemented in SingleWeakRefMaker.

CoreExport SClass_ID SuperClassID ( ) [virtual]

Retrieves a constant representing the type of the plugin.

Returns:
A super class id that uniquely identifies the type (category) of the plugin. Note that several plugin classes can be of the same type, thus return the same super class id. Plugins are uniquely identified by their class ids. List of Super Class IDs.
See also:
SClass_ID

Reimplemented from ReferenceMaker.

Reimplemented in SingleWeakRefMaker.

CoreExport int NumRefs ( ) [virtual]

Returns the total number of references this ReferenceMaker can hold.

The plugin implements this method to indicate the total number of of references it can make. This includes all references whether they are NULL (inactive) or non-NULL (active) at the time when this method is called. A plugin can hold a variable number of references, thus the return value of this method is not to be cached and reused by client code.

Returns:
The total number of references this plugin can hold. The default implementation is return 0.

Reimplemented from ReferenceMaker.

CoreExport RefTargetHandle GetReference ( int  i ) [virtual]

Returns the 'i-th' reference.

The plugin implements this method to return its 'i-th' reference. The plug-in simply keeps track of its references using an integer index for each one. This method is normally called by the system.

Parameters:
i - The index of the reference to retrieve. Valid values are from 0 to NumRefs()-1.
Returns:
The reference handle of the 'i-th' reference. Note that different calls to this method with the same 'i' value can result in different reference handles being retrieved, as the plugin changes the scene objects it references as its 'i-th' reference.

Reimplemented from ReferenceMaker.

virtual CoreExport void SetReference ( int  i,
RefTargetHandle  rtarg 
) [protected, virtual]

Stores a ReferenceTarget as its 'i-th' reference`.

The plugin implements this method to store the reference handle passed to it as its 'i-th' reference. In its implementation of this method, the plugin should simply assign the reference handle passed in as a parameter to the member variable that holds the 'i-th' reference. Other reference handling methods such as ReferenceMaker::DeleteReference(), or ReferenceMaker::ReplaceReference() should not be called from within this method. The plugin itself or other plugins should not call this method directly. The system will call this method when a new reference is created or an existing one is replaced by calling ReferenceMaker::ReplaceReference().

Parameters:
i - The index of the reference to store. Valid values are from 0 to NumRefs()-1.
rtarg - The reference handle to store.

Reimplemented from ReferenceMaker.

CoreExport BOOL CanTransferReference ( int  i ) [virtual]

Tells whether this reference can be transfered.

A ReferenceMaker can choose not to let ReferenceTarget::TransferReferences() affect it. Note that plugins probably should not use this. It is used by certain system objects that have references.

Parameters:
i - Currently not used.
Returns:
Default to return TRUE

Reimplemented from ReferenceMaker.


Member Data Documentation

RefTargetHandle rtarget [protected]

Handle to the single reference.


SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker
SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker SingleRefMaker