3ds Max C++ API Reference
AppDataChunk Class Reference

An application/plugin specific custom data that can be attached to animatables. More...

#include <AppDataChunk.h>

+ Inheritance diagram for AppDataChunk:

Public Member Functions

CoreExport AppDataChunk (const Class_ID &cid, SClass_ID sid, DWORD sbid, DWORD len, void *data)
 Constructor. More...
 
CoreExport AppDataChunk ()
 Constructor The length of the data buffer is set to 0 and the data pointer set to NULL. More...
 
CoreExport ~AppDataChunk ()
 Destructor. More...
 
CoreExport IOResult Load (ILoad *iload)
 Loads this AppDataChunk. More...
 
CoreExport IOResult Save (ISave *isave)
 Saves this AppDataChunk. More...
 

Public Attributes

Class_ID classID
 The Class_ID of the owner of this chunk. More...
 
SClass_ID superClassID
 The SuperClassID of the owner of this chunk. More...
 
DWORD subID
 An extra ID that lets the owner identify its sub chunks. More...
 
DWORD length
 The length of the data in bytes. More...
 
voiddata
 The chunk data itself. 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

An application/plugin specific custom data that can be attached to animatables.

Instances of this class store custom data defined by plugins and are attached to animatables when plugins call Animatable::AddAppDataChunk. Plugins don't need to instantiate directly objects of type AppDataChunk, but can get to the instances stored on animatables by calling Animatable::GetAppDataChunk.

Example
This example is from samples/utilities/appdata.cpp:
void AppDataTest::GetAppData()
{
Animatable *anim = PickAnim();
if (!anim) return;
if (s_through_xref) {
IXRefItem* xi = NULL;
while (rth != NULL && (xi = IXRefItem::GetInterface(*rth)) != NULL)
rth = xi->GetSrcItem();
if (rth != NULL)
anim = rth;
}
// If the Animatable is an object xref, get its source item on which we'll look for the appdata.
AppDataChunk *ad =
APPDATA_TEST_CLASS_ID,
spin->GetIVal());
if (ad && ad->data) {
// Fill the edit field with the text.
const char* raw_string = (const char*)ad->data;
if (strncmp(raw_string, "\xef\xbb\xbf", 3) == 0)
data = TSTR::FromUTF8(raw_string+3);
else
{
DbgAssert(!_T("Should always convert appdata in UpdateAppDataLoadProc"));
LANGID langID = iface->LanguageToUseForFileIO();
UINT codePage = iface->CodePageForLanguage(langID);
data = TSTR::FromCP(codePage, raw_string);
}
SetDlgItemText(hPanel,IDC_APPDATA_EDIT,data.data());
} else {
// Not found!
MaxSDK::MaxMessageBox(hPanel, _T("No app data found"), _T("App Data Tester"), MB_OK);
}
}
#define NULL
Definition: autoptr.h:18
Definition: Animatable.h:118
CoreExport AppDataChunk * GetAppDataChunk(const Class_ID &cid, SClass_ID sid, DWORD sbid)
Retrieves the application/plugin specific (custom) data stored with an Animatable.
An application/plugin specific custom data that can be attached to animatables.
Definition: AppDataChunk.h:29
void * data
The chunk data itself.
Definition: AppDataChunk.h:70
Generic interface that represents an xrefed scene entity.
Definition: iXrefItem.h:46
virtual BaseInterface * GetInterface(Interface_ID id)
Definition: ifnpub.h:595
virtual ReferenceTarget * GetSrcItem(bool resolveNested=false) const =0
Retrieves the source scene entity xrefed by this xref item.
Extends Interface13 Client code should retrieve this interface using GetCOREInterface14.
Definition: maxapi.h:9782
virtual LANGID LanguageToUseForFileIO() const =0
The LANGID to use for scene, text, and other binary file io when doing string conversions.
virtual UINT CodePageForLanguage(LANGID id) const =0
returns the code page corresponding to the specified LANGID.
A scene entity that is being owned and listened to by other scene entities.
Definition: ref.h:1844
#define DbgAssert(expr)
Definition: assert1.h:82
#define UTILITY_CLASS_ID
Utility object super-class ID.
Definition: plugapi.h:429
CoreExport Interface14 * GetCOREInterface14()
UtilExport int MaxMessageBox(HWND parent, LPCMSTR text, LPCMSTR caption, unsigned int type, unsigned int exType=0, DWORD *exRet=nullptr)
Provides an extended message box functionality. This is used to support message dialogs with a 'Hold'...
ReferenceTarget * RefTargetHandle
Creates a typename for ReferenceTarget pointers.
Definition: ref.h:808
#define TSTR
Definition: strclass.h:1054

Constructor & Destructor Documentation

◆ AppDataChunk() [1/2]

CoreExport AppDataChunk ( const Class_ID cid,
SClass_ID  sid,
DWORD  sbid,
DWORD  len,
void data 
)

Constructor.

The data members are initialized to the values passed.

Parameters
cid- The Class_ID of the owner of the custom data.
sid- The SuperClassID of the owner of the custom data.
sbid- An extra ID that lets the owner identify its sub-custom-data (chunks).
len- The length of the data in bytes.
data- Pointer to the actual data. The data should be allocated on the heap by client code using MAX_malloc(). This will allow the system to free it safely (using MAX_free()). MAX_malloc() and MAX_free() are memory management routines implemented by the system.
Note
Important: Not allocating on the heap the data passed to this method may lead to unexpected behavior of the application.
Important: Client code does not need to free the data that has been passed to this method. The system will free it when the Animatable is deleted or when client code explicitly removes the custom data chunk from the Animatable by calling Animatable::RemoveAppDataChunk.

◆ AppDataChunk() [2/2]

Constructor The length of the data buffer is set to 0 and the data pointer set to NULL.

◆ ~AppDataChunk()

Destructor.

The data buffer is freed using MAX_free(). This implies that plug-ins must use MAX_malloc() to allocate it.

Member Function Documentation

◆ Load()

CoreExport IOResult Load ( ILoad iload)

Loads this AppDataChunk.

The system implements this method to load the AppDataChunk from disk.

◆ Save()

CoreExport IOResult Save ( ISave isave)

Saves this AppDataChunk.

The system implements this method to save the AppDataChunk to disk.

Member Data Documentation

◆ classID

Class_ID classID

The Class_ID of the owner of this chunk.

◆ superClassID

SClass_ID superClassID

The SuperClassID of the owner of this chunk.

◆ subID

DWORD subID

An extra ID that lets the owner identify its sub chunks.

◆ length

DWORD length

The length of the data in bytes.

◆ data

void* data

The chunk data itself.