EngineObject

Engine/source/console/engineObject.h

Base class for all objects that may be passed to the control layer.

More...

Protected Types

__IsDisposableType 
__IsSingletonType 

Public Attributes

Public Friends

Return the type info object for the dynamic type of the given object.

Protected Attributes

Private Attributes

Object pool to which this object belongs.

void *

Opaque user data pointer that the control layer may install on any engine object.

Public Functions

Return a string that describes this instance. Meant primarily for debugging.

object destroy self call (from StrongRefPtr). Override if this class has specially allocated memory.

Return the pool of EngineObjects to which this object belongs.

Release the given object's memory in the pool it has been allocated from.

void *
operator new(size_t size TORQUE_TMM_ARGS_DECL)

Allocate a new object in the default object pool.

void *
operator new(size_t size)
void *
operator new(size_t size, IEngineObjectPool *pool TORQUE_TMM_ARGS_DECL)

Allocate a new object in the given object pool.

void *
operator new(size_t size, IEngineObjectPool * pool)
void *
operator new(size_t size, void * ptr)

Placement new.

Protected Functions

Subclasses should overload this method instead of the public destroySelf().

Protected Static Functions

void *
_allocateObject(size_t size, IEngineObjectPool *pool TORQUE_TMM_ARGS_DECL)

Private Functions

Detailed Description

Base class for all objects that may be passed to the control layer.

A set of rules applies to all EngineObject-derived classes:

  • Every EngineObject class must have a default constructor.

  • The default constructor and the destructor of every EngineObject class must be public.

  • If an EngineObject class inherits from multiple classes, the class leading back to EngineObject must be the first class in the list to ensure binary-compatible class layouts.

  • EngineObjects are cooperatively reference-counted by both the engine as well as the control layer.

Protected Types

typedef ::FalseType __IsDisposableType 
typedef ::FalseType __IsSingletonType 

Public Attributes

 DECLARE_INSTANTIABLE 

Public Friends

Protected Attributes

 DEFINE_CREATE_METHOD 
return object 

Private Attributes

IEngineObjectPool * mEngineObjectPool 

Object pool to which this object belongs.

If this is NULL, the object will not deallocate itself when it is destructed. This is useful for inline allocation of objects.

void * mEngineObjectUserData 

Opaque user data pointer that the control layer may install on any engine object.

Most importantly, this allows control layers to very easily keep track of EngineObjects that they have already created their own wrapper objects for.

Public Functions

EngineObject()

~EngineObject()

DECLARE_ABSTRACT_CLASS(EngineObject , void )

DECLARE_INSCOPE(_GLOBALSCOPE )

describeSelf()

Return a string that describes this instance. Meant primarily for debugging.

Reimplemented by: SimObject, SceneRootZone, SceneSimpleZone, NetObject, Portal

destroySelf()

Reimplemented from: StrongRefBase

Reimplemented by: StaticEngineObject, SimObject

getEngineObjectPool()

Return the pool of EngineObjects to which this object belongs.

operator delete(void * ptr)

Release the given object's memory in the pool it has been allocated from.

operator new(size_t size TORQUE_TMM_ARGS_DECL)

Allocate a new object in the default object pool.

Parameters:

size

Size of the object in bytes.

return:

Memory block for new object; never NULL.

operator new(size_t size)

operator new(size_t size, IEngineObjectPool *pool TORQUE_TMM_ARGS_DECL)

Allocate a new object in the given object pool.

If the given pool's allocateObject returns NULL, the method will fall back to the default pool.

Parameters:

size

Size of the object in bytes.

pool

Object pool to allocate the object in.

return:

Memory block for the new object; never NULL.

operator new(size_t size, IEngineObjectPool * pool)

operator new(size_t size, void * ptr)

Placement new.

Protected Functions

_destroySelf()

Subclasses should overload this method instead of the public destroySelf().

Reimplemented by: SimObject

incRefCount()

Protected Static Functions

_allocateObject(size_t size, IEngineObjectPool *pool TORQUE_TMM_ARGS_DECL)

Private Functions

operator delete[](void * )

operator new[](size_t )