AppDataChunk Class Reference

#include <AppDataChunk.h>

Class 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!
MessageBox(hPanel,_T("No app data found"),_T("App Data Tester"),MB_OK);
}
}
+ 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...
 

Constructor & Destructor Documentation

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.

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

Destructor.

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

Member Function Documentation

CoreExport IOResult Load ( ILoad iload)

Loads this AppDataChunk.

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

CoreExport IOResult Save ( ISave isave)

Saves this AppDataChunk.

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

Member Data Documentation

Class_ID classID

The Class_ID of the owner of this chunk.

SClass_ID superClassID

The SuperClassID of the owner of this chunk.

DWORD subID

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

DWORD length

The length of the data in bytes.

void* data

The chunk data itself.