Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SoMemoryError Class Reference

The SoMemoryError class is used to inform of problems with memory allocation. More...

#include <Inventor/errors/SoMemoryError.h>

Inheritance diagram for SoMemoryError:
SoError

Public Member Functions

virtual SoType getTypeId (void) const
 
- Public Member Functions inherited from SoError
virtual ~SoError ()
 
const SbStringgetDebugString (void) const
 
SbBool isOfType (const SoType type) const
 

Static Public Member Functions

static SoType getClassTypeId (void)
 
static SoErrorCB * getHandlerCallback (void)
 
static voidgetHandlerData (void)
 
static void initClass (void)
 
static void post (const char *const whatWasAllocated)
 
static void setHandlerCallback (SoErrorCB *const callback, void *const data)
 
- Static Public Member Functions inherited from SoError
static SoType getClassTypeId (void)
 
static SoErrorCB * getHandlerCallback (void)
 
static voidgetHandlerData (void)
 
static SbString getString (const SoEngine *const engine)
 
static SbString getString (const SoNode *const node)
 
static SbString getString (const SoPath *const path)
 
static void initClass (void)
 
static void initClasses (void)
 
static void post (const char *const format,...)
 
static void setHandlerCallback (SoErrorCB *const func, void *const data)
 

Protected Member Functions

virtual SoErrorCBPtr getHandler (void *&data) const
 
- Protected Member Functions inherited from SoError
void appendToDebugString (const char *const str)
 
void handleError (void)
 
void setDebugString (const char *const str)
 

Additional Inherited Members

- Static Protected Member Functions inherited from SoError
static void defaultHandlerCB (const SoError *error, void *userdata)
 

Detailed Description

The SoMemoryError class is used to inform of problems with memory allocation.

Modern operating systems takes care of handling most out of memory conditions for you, but in certain situations it can be wise to do some manual checking and intervention. This class is provided as an aid to help out in these situations.

The basic design of the Coin library is to pass on the responsibility for handling failed attempts at memory allocation to the application programmer. If you want to detect and take care of these, you should compile Coin with the C++ exception throwing on and wrap your code within try{} and catch{} blocks. The most you can do if you get a failed allocation is typically to notify the user and then exit the application, though, and this is something most operating systems will do for you, so you probably need not consider this at all.

So, where does the SoMemoryError class come in handy? There are certain things which could happen within the library which are best taken care of by internally handling failed attempts at memory allocation. An example: the user tries to load a model file which contains a filename pointer to a huge bitmap file with a texture map. The end-user's system does not provide enough memory to load the file and prepare the texture image for rendering, though. This is a case where it is possible to just emit a warning and continue. The warning will then be passed through this class.

Note that SoMemoryError is probably not of much use to the application programmer.

Member Function Documentation

◆ getClassTypeId()

SoType SoMemoryError::getClassTypeId ( void )
static

This static method returns the SoType for this class.

See also
getTypeId()

◆ getHandler()

SoErrorCB * SoMemoryError::getHandler ( void *& data) const
protectedvirtual

This is just a convenience wrapper around the getHandlerCallback() and getHandlerData() methods.

Reimplemented from SoError.

◆ getHandlerCallback()

SoErrorCB * SoMemoryError::getHandlerCallback ( void )
static

Returns the error handler callback for messages posted via this class.

◆ getHandlerData()

void * SoMemoryError::getHandlerData ( void )
static

This method returns the pointer used for passing data back to the callback handler method.

◆ getTypeId()

SoType SoMemoryError::getTypeId ( void ) const
virtual

This method returns the SoType of a particular object instance.

See also
getClassTypeId()

Reimplemented from SoError.

◆ initClass()

void SoMemoryError::initClass ( void )
static

This method takes care of initializing all static data for the class.

◆ post()

void SoMemoryError::post ( const char *const whatWasAllocated)
static

Posts a warning about a failed memory allocation. whatWasAllocated should contain a description of what we tried to allocate.

◆ setHandlerCallback()

void SoMemoryError::setHandlerCallback ( SoErrorCB *const function,
void *const data )
static

This method sets the error handler callback for messages posted via this class.

Note that this will not override the error/debug message handler for subclasses, these will have to be overridden by calling the subclass' setHandlerCallback() method.

See also
defaultHandlerCB()

The documentation for this class was generated from the following files: