Torque2D Reference
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
SimObject Class Reference

#include <simObject.h>

+ Inheritance diagram for SimObject:

Classes

struct  Notify
 

Public Types

enum  WriteFlags { SelectedOnly = BIT(0) }
 

Public Member Functions

StringTableEntry getClassNamespace () const
 
StringTableEntry getSuperClassNamespace () const
 
void setClassNamespace (const char *classNamespace)
 
void setSuperClassNamespace (const char *superClassNamespace)
 
void pushScriptCallbackGuard (void)
 
void popScriptCallbackGuard (void)
 
S32 getScriptCallbackGuard (void)
 
virtual SimObjectfindObject (const char *name)
 
NamespacegetNamespace ()
 Return the object's namespace. More...
 
const char * tabComplete (const char *prevText, S32 baseLen, bool)
 
virtual void dump ()
 
virtual void dumpClassHierarchy ()
 
SimObjectclone (const bool copyDynamicFields)
 
virtual void copyTo (SimObject *object)
 
template<typename T >
bool isType (void)
 
virtual bool handlesConsoleMethod (const char *fname, S32 *routingId)
 
 DECLARE_CONOBJECT (SimObject)
 
- Public Member Functions inherited from ConsoleObject
const AbstractClassRep::FieldfindField (StringTableEntry fieldName) const
 Get a reference to a field by name. More...
 
virtual AbstractClassRepgetClassRep () const
 Gets the ClassRep. More...
 
bool setField (const char *fieldName, const char *value)
 Set the value of a field. More...
 
virtual ~ConsoleObject ()
 
const AbstractClassRep::FieldListgetFieldList () const
 Get a list of all the fields. This information cannot be modified. More...
 
AbstractClassRep::FieldListgetModifiableFieldList ()
 
bool & getDynamicGroupExpand ()
 
S32 getClassId (U32 netClassGroup) const
 
const char * getClassName () const
 

Static Public Member Functions

static void initPersistFields ()
 
- Static Public Member Functions inherited from ConsoleObject
static const char * lookupClassName (const U32 in_classTag)
 Get the classname from a class tag. More...
 
static void initPersistFields ()
 
static void consoleInit ()
 
static ConsoleObjectcreate (const char *in_pClassName)
 
static ConsoleObjectcreate (const U32 groupId, const U32 typeId, const U32 in_classId)
 
static AbstractClassRepgetStaticClassRep ()
 Get the abstract class information for this class. More...
 
static AbstractClassRepgetParentStaticClassRep ()
 Get the abstract class information for this class's superclass. More...
 

Protected Member Functions

virtual void onTamlPreWrite (void)
 Taml callbacks. More...
 
virtual void onTamlPostWrite (void)
 Called after Taml has finished writing the object. More...
 
virtual void onTamlPreRead (void)
 Called prior to Taml reading the object. More...
 
virtual void onTamlPostRead (const TamlCustomNodes &customNodes)
 
virtual void onTamlAddParent (SimObject *pParentObject)
 Called after Taml has finished reading the object and has added the object to any parent. More...
 
virtual void onTamlCustomWrite (TamlCustomNodes &customNodes)
 Called during the writing of the object to allow custom properties to be written. More...
 
virtual void onTamlCustomRead (const TamlCustomNodes &customNodes)
 Called during the reading of the object to allow custom properties to be read. More...
 
void linkNamespaces ()
 
void unlinkNamespaces ()
 
- Protected Member Functions inherited from ConsoleObject
 ConsoleObject ()
 
 ConsoleObject (const ConsoleObject &)
 

Static Protected Member Functions

static bool setClass (void *obj, const char *data)
 
static bool setSuperClass (void *obj, const char *data)
 
static bool writeCanSaveDynamicFields (void *obj, StringTableEntry pFieldName)
 
static bool writeInternalName (void *obj, StringTableEntry pFieldName)
 
static bool setParentGroup (void *obj, const char *data)
 
static bool writeParentGroup (void *obj, StringTableEntry pFieldName)
 
static bool writeSuperclass (void *obj, StringTableEntry pFieldName)
 
static bool writeClass (void *obj, StringTableEntry pFieldName)
 
- Static Protected Member Functions inherited from ConsoleObject
static void addGroup (const char *in_pGroupname, const char *in_pGroupDocs=NULL)
 
static void endGroup (const char *in_pGroupname)
 
static void addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
 
static void addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::WriteDataNotify in_writeDataFn, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
 
static void addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, const char *in_pFieldDocs)
 
static void addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::WriteDataNotify in_writeDataFn, const char *in_pFieldDocs)
 
static void addFieldV (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, ConsoleTypeValidator *v, const char *in_pFieldDocs=NULL)
 
static void addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
 
static void addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, AbstractClassRep::WriteDataNotify in_writeDataFn=&defaultProtectedWriteFn, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
 
static void addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, const char *in_pFieldDocs=NULL)
 
static void addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, AbstractClassRep::WriteDataNotify in_writeDataFn=&defaultProtectedWriteFn, const char *in_pFieldDocs=NULL)
 
static void addDepricatedField (const char *fieldName)
 
static bool removeField (const char *in_pFieldname)
 

Protected Attributes

SimObjectId mId
 Id number for this object. More...
 
StringTableEntry mIdString
 
NamespacemNameSpace
 
U32 mTypeMask
 
S32 mScriptCallbackGuard
 Whether the object is executing a script callback. More...
 
bool mCanSaveFieldDictionary
 true if dynamic fields (added at runtime) should be saved, defaults to true More...
 
StringTableEntry mInternalName
 Stores object Internal Name. More...
 
StringTableEntry mClassName
 Stores the class name to link script class namespaces. More...
 
StringTableEntry mSuperClassName
 Stores super class name to link script class namespaces. More...
 

Friends

class SimManager
 
class SimGroup
 
class SimNameDictionary
 
class SimManagerNameDictionary
 
class SimIdDictionary
 

Notification

static SimObject::NotifymNotifyFreeList = NULL
 
static SimObject::NotifyallocNotify ()
 Get a free Notify structure. More...
 
static void freeNotify (SimObject::Notify *)
 Mark a Notify structure as free. More...
 
NotifyremoveNotify (void *ptr, Notify::Type)
 Remove a notification from the list. More...
 
void deleteNotify (SimObject *obj)
 Notify an object when we are deleted. More...
 
void clearNotify (SimObject *obj)
 Notify an object when we are cleared. More...
 
void clearAllNotifications ()
 Remove all notifications for this object. More...
 
void processDeleteNotifies ()
 Send out deletion notifications. More...
 
void registerReference (SimObject **obj)
 
void unregisterReference (SimObject **obj)
 

Accessors

const char * getDataField (StringTableEntry slotName, const char *array)
 
void setDataField (StringTableEntry slotName, const char *array, const char *value)
 
const char * getPrefixedDataField (StringTableEntry fieldName, const char *array)
 
void setPrefixedDataField (StringTableEntry fieldName, const char *array, const char *value)
 
const char * getPrefixedDynamicDataField (StringTableEntry fieldName, const char *array, const S32 fieldType=-1)
 
void setPrefixedDynamicDataField (StringTableEntry fieldName, const char *array, const char *value, const S32 fieldType=-1)
 
StringTableEntry getDataFieldPrefix (StringTableEntry fieldName)
 
U32 getDataFieldType (StringTableEntry slotName, const char *array)
 
SimFieldDictionarygetFieldDictionary ()
 
void clearDynamicFields (void)
 Clear all dynamic fields. More...
 
void setCanSaveDynamicFields (bool bCanSave)
 Set whether fields created at runtime should be saved. Default is true. More...
 
bool getCanSaveDynamicFields (void) const
 Get whether fields created at runtime should be saved. Default is true. More...
 
void setInternalName (const char *newname)
 
StringTableEntry getInternalName ()
 Get the internal of of this control. More...
 
virtual bool save (const char *pcFilePath, bool bOnlySelected=false)
 Save object as a TorqueScript File. More...
 
virtual bool isMethod (const char *methodName)
 Check if a method exists in the objects current namespace. More...
 
SimObjectId getId (void) const
 
StringTableEntry getIdString (void) const
 
U32 getType () const
 
const StringTableEntry getName (void) const
 
void setId (SimObjectId id)
 
void assignName (const char *name)
 
SimGroupgetGroup () const
 
bool isChildOfGroup (SimGroup *pGroup)
 
bool isProperlyAdded () const
 
bool isDeleted () const
 
bool isRemoved () const
 
bool isLocked ()
 
void setLocked (bool b)
 
bool isHidden ()
 
void setHidden (bool b)
 
void setProgenitorFile (const char *pFile)
 
StringTableEntry getProgenitorFile (void) const
 
void setPeriodicTimerID (const S32 timerID)
 
S32 getPeriodicTimerID (void) const
 
bool isPeriodicTimerActive (void) const
 
bool isSelected () const
 
bool isExpanded () const
 
void setSelected (bool sel)
 
void setExpanded (bool exp)
 
void setModDynamicFields (bool dyn)
 
void setModStaticFields (bool sta)
 

Initialization

 SimObject ()
 
virtual ~SimObject ()
 
virtual bool processArguments (S32 argc, const char **argv)
 Process constructor options. (ie, new SimObject(1,2,3)) More...
 

Events

virtual bool onAdd ()
 Called when the object is added to the sim. More...
 
virtual void onRemove ()
 Called when the object is removed from the sim. More...
 
virtual void onGroupAdd ()
 Called when the object is added to a SimGroup. More...
 
virtual void onGroupRemove ()
 Called when the object is removed from a SimGroup. More...
 
virtual void onNameChange (const char *name)
 Called when the object's name is changed. More...
 
virtual void onStaticModified (const char *slotName, const char *newValue=NULL)
 
virtual void inspectPreApply ()
 
virtual void inspectPostApply ()
 
virtual void onDeleteNotify (SimObject *object)
 
virtual void onEditorEnable ()
 Called when the editor is activated. More...
 
virtual void onEditorDisable ()
 Called when the editor is deactivated. More...
 

Registration

SimObjects must be registered with the object system.

bool registerObject ()
 
bool registerObject (U32 id)
 
bool registerObject (const char *name)
 
bool registerObject (const char *name, U32 id)
 
void unregisterObject ()
 
void deleteObject ()
 

Sets

The object must be properly registered before you can add/remove it to/from a set.

All these functions accept either a name or ID to identify the set you wish to operate on. Then they call addObject or removeObject on the set, which sets up appropriate notifications.

An object may be in multiple sets at a time.

bool addToSet (SimObjectId)
 
bool addToSet (const char *)
 
bool removeFromSet (SimObjectId)
 
bool removeFromSet (const char *)
 

Serialization

virtual bool writeField (StringTableEntry fieldname, const char *value)
 
virtual void write (Stream &stream, U32 tabStop, U32 flags=0)
 
virtual void writeFields (Stream &stream, U32 tabStop)
 
virtual bool writeObject (Stream *stream)
 
virtual bool readObject (Stream *stream)
 
virtual void buildFilterList ()
 
void addFieldFilter (const char *fieldName)
 
void removeFieldFilter (const char *fieldName)
 
void clearFieldFilters ()
 
bool isFiltered (const char *fieldName)
 
void assignFieldsFrom (SimObject *obj)
 
void assignDynamicFieldsFrom (SimObject *obj)
 

Detailed Description

Base class for objects involved in the simulation.

Introduction

SimObject is a base class for most of the classes you'll encounter working in Torque. It provides fundamental services allowing "smart" object referencing, creation, destruction, organization, and location. Along with SimEvent, it gives you a flexible event-scheduling system, as well as laying the foundation for the in-game editors, GUI system, and other vital subsystems.

Subclassing

You will spend a lot of your time in Torque subclassing, or working with subclasses of, SimObject. SimObject is designed to be easy to subclass.

You should not need to override anything in a subclass except:

Of course, if you know what you're doing, go nuts! But in most cases, you shouldn't need to touch things not on that list.

When you subclass, you should define a typedef in the class, called Parent, that references the class you're inheriting from.

class mySubClass : public SimObject {
typedef SimObject Parent;
...

Then, when you override a method, put in:

bool mySubClass::onAdd()
{
if(!Parent::onAdd())
return false;
// ... do other things ...
}

Of course, you want to replace onAdd with the appropriate method call.

A SimObject's Life Cycle

SimObjects do not live apart. One of the primary benefits of using a SimObject is that you can uniquely identify it and easily find it (using its ID). Torque does this by keeping a global hierarchy of SimGroups - a tree - containing every registered SimObject. You can then query for a given object using Sim::findObject() (or SimSet::findObject() if you want to search only a specific set).

// Three examples of registering an object.
// Method 1:
AIClient *aiPlayer = new AIClient();
aiPlayer->registerObject();
// Method 2:
ActionMap* globalMap = new ActionMap;
globalMap->registerObject("GlobalActionMap");
// Method 3:
bool reg = mObj->registerObject(id);

Registering a SimObject performs these tasks:

Calling registerObject() and passing an ID or a name will cause the object to be assigned that name and/or ID before it is registered.

Congratulations, you have now registered your object! What now?

Well, hopefully, the SimObject will have a long, useful life. But eventually, it must die.

There are a two ways a SimObject can die.

When you unregister a SimObject, the following tasks are performed:

If you call deleteObject(), all of the above tasks are performed, in addition to some sanity checking to make sure the object was previously added properly, and isn't in the process of being deleted. After the object is unregistered, it de-allocates itself.

Torque Editors

SimObjects are one of the building blocks for the in-game editors. They provide a basic interface for the editor to be able to list the fields of the object, update them safely and reliably, and inform the object things have changed.

This interface is implemented in the following areas:

(Note: you can check the variable gEditingMission to see if the mission editor is running; if so, you may want to render special indicators. For instance, the fxFoliageReplicator renders inner and outer radii when the mission editor is running.)

The Console

SimObject extends ConsoleObject by allowing you to to set arbitrary dynamic fields on the object, as well as statically defined fields. This is done through two methods, setDataField and getDataField, which deal with the complexities of allowing access to two different types of object fields.

Static fields take priority over dynamic fields. This is to be expected, as the role of dynamic fields is to allow data to be stored in addition to the predefined fields.

The fields in a SimObject are like properties (or fields) in a class.

Some fields may be arrays, which is what the array parameter is for; if it's non-null, then it is parsed with dAtoI and used as an index into the array. If you access something as an array which isn't, then you get an empty string.

You don't need to read any further than this. Right now, set/getDataField are called a total of 6 times through the entire Torque codebase. Therefore, you probably don't need to be familiar with the details of accessing them. You may want to look at Con::setData instead. Most of the time you will probably be accessing fields directly, or using the scripting language, which in either case means you don't need to do anything special.

The functions to get/set these fields are very straightforward:

setDataField(StringTable->insert("locked", false), NULL, b ? "true" : "false" );
curObject->setDataField(curField, curFieldArray, STR.getStringValue());
setDataField(slotName, array, value);

For advanced users: There are two flags which control the behavior of these functions. The first is ModStaticFields, which controls whether or not the DataField functions look through the static fields (defined with addField; see ConsoleObject for details) of the class. The second is ModDynamicFields, which controls dynamically defined fields. They are set automatically by the console constructor code.

Member Enumeration Documentation

enum WriteFlags
Enumerator
SelectedOnly 

Passed to SimObject::write to indicate that only objects

Constructor & Destructor Documentation

SimObject ( )
~SimObject ( )
virtual

Member Function Documentation

void addFieldFilter ( const char *  fieldName)
bool addToSet ( SimObjectId  spid)
bool addToSet ( const char *  ObjectName)
SimObject::Notify * allocNotify ( )
staticprotected

Get a free Notify structure.

void assignDynamicFieldsFrom ( SimObject obj)

Copy dynamic fields from another object onto this one.

Everything from obj will overwrite what's in this object.

Parameters
objObject to copy from.
void assignFieldsFrom ( SimObject obj)

Copy fields from another object onto this one.

Objects must be of same type. Everything from obj will overwrite what's in this object; extra fields in this object will remain. This includes dynamic fields.

Parameters
objObject to copy from.
void assignName ( const char *  name)
void buildFilterList ( )
virtual
void clearAllNotifications ( )

Remove all notifications for this object.

void clearDynamicFields ( void  )
inline

Clear all dynamic fields.

void clearFieldFilters ( )
void clearNotify ( SimObject obj)

Notify an object when we are cleared.

SimObject * clone ( const bool  copyDynamicFields)
void copyTo ( SimObject object)
virtual
DECLARE_CONOBJECT ( SimObject  )
void deleteNotify ( SimObject obj)

Notify an object when we are deleted.

void deleteObject ( )

Unregister, mark as deleted, and free the object.

void dump ( )
virtual
void dumpClassHierarchy ( )
virtual
SimObject * findObject ( const char *  name)
virtual

Find a named sub-object of this object.

This is subclassed in the SimGroup and SimSet classes.

For a single object, it just returns NULL, as normal objects cannot have children.

Reimplemented in SimGroup, SimSet, and SceneObjectSet.

void freeNotify ( SimObject::Notify note)
staticprotected

Mark a Notify structure as free.

bool getCanSaveDynamicFields ( void  ) const
inline

Get whether fields created at runtime should be saved. Default is true.

StringTableEntry getClassNamespace ( ) const
inline
const char * getDataField ( StringTableEntry  slotName,
const char *  array 
)

Get the value of a field on the object.

See here for a detailed discussion of what this function does.

Parameters
slotNameField to access.
arrayString containing index into array (if field is an array); if NULL, it is ignored.
StringTableEntry getDataFieldPrefix ( StringTableEntry  fieldName)
U32 getDataFieldType ( StringTableEntry  slotName,
const char *  array 
)

Get the type of a field on the object.

Parameters
slotNameField to access.
arrayString containing index into array (if field is an array); if NULL, it is ignored.
SimFieldDictionary* getFieldDictionary ( )
inline

Get reference to the dictionary containing dynamic fields.

See here for a detailed discussion of what this function does.

This dictionary can be iterated over using a SimFieldDictionaryIterator.

SimGroup* getGroup ( ) const
inline
SimObjectId getId ( void  ) const
inline
StringTableEntry getIdString ( void  ) const
inline
StringTableEntry getInternalName ( )

Get the internal of of this control.

const StringTableEntry getName ( void  ) const
inline
Namespace* getNamespace ( )
inline

Return the object's namespace.

S32 getPeriodicTimerID ( void  ) const
inline
const char * getPrefixedDataField ( StringTableEntry  fieldName,
const char *  array 
)
const char * getPrefixedDynamicDataField ( StringTableEntry  fieldName,
const char *  array,
const S32  fieldType = -1 
)
StringTableEntry getProgenitorFile ( void  ) const
inline
S32 getScriptCallbackGuard ( void  )
inline
StringTableEntry getSuperClassNamespace ( ) const
inline
U32 getType ( ) const
inline
virtual bool handlesConsoleMethod ( const char *  fname,
S32 *  routingId 
)
inlinevirtual
void initPersistFields ( void  )
static
void inspectPostApply ( )
virtual
void inspectPreApply ( )
virtual

Specifically, this is called by setDataField when a static field is modified, see the console details. Called before any property of the object is changed in the world editor.

The calling order here is:

Reimplemented in GuiControl.

bool isChildOfGroup ( SimGroup pGroup)
bool isDeleted ( ) const
inline
bool isExpanded ( ) const
inline
bool isFiltered ( const char *  fieldName)
bool isHidden ( )
bool isLocked ( )
bool isMethod ( const char *  methodName)
virtual

Check if a method exists in the objects current namespace.

bool isPeriodicTimerActive ( void  ) const
inline
bool isProperlyAdded ( ) const
inline
bool isRemoved ( ) const
inline
bool isSelected ( ) const
inline
bool isType ( void  )
inline
void linkNamespaces ( )
protected
bool onAdd ( void  )
virtual
void onDeleteNotify ( SimObject object)
virtual

Called when a SimObject is deleted.

When you are on the notification list for another object and it is deleted, this method is called.

Reimplemented in Scene, SimSet, ModuleManager, UInputManager, SceneObjectSet, BehaviorComponent, and ParticleAsset.

virtual void onEditorDisable ( )
inlinevirtual

Called when the editor is deactivated.

virtual void onEditorEnable ( )
inlinevirtual

Called when the editor is activated.

void onGroupAdd ( )
virtual

Called when the object is added to a SimGroup.

void onGroupRemove ( )
virtual

Called when the object is removed from a SimGroup.

void onNameChange ( const char *  name)
virtual

Called when the object's name is changed.

void onRemove ( )
virtual
void onStaticModified ( const char *  slotName,
const char *  newValue = NULL 
)
virtual

Called when a static field is modified.

Reimplemented in SimDataBlock.

virtual void onTamlAddParent ( SimObject pParentObject)
inlineprotectedvirtual

Called after Taml has finished reading the object and has added the object to any parent.

Implements TamlCallbacks.

Reimplemented in ParticlePlayer.

virtual void onTamlCustomRead ( const TamlCustomNodes customNodes)
inlineprotectedvirtual

Called during the reading of the object to allow custom properties to be read.

Implements TamlCallbacks.

Reimplemented in Scene, ImageAsset, ParticleAssetEmitter, SceneObject, ParticleAsset, AssetTagsManifest, CompositeSprite, SkeletonAsset, BehaviorComponent, and AssetQuery.

virtual void onTamlCustomWrite ( TamlCustomNodes customNodes)
inlineprotectedvirtual

Called during the writing of the object to allow custom properties to be written.

Implements TamlCallbacks.

Reimplemented in Scene, ImageAsset, ParticleAssetEmitter, SceneObject, ParticleAsset, AssetTagsManifest, CompositeSprite, SkeletonAsset, BehaviorComponent, and AssetQuery.

virtual void onTamlPostRead ( const TamlCustomNodes customNodes)
inlineprotectedvirtual

Called after Taml has finished reading the object. The custom properties is additionally passed here for object who want to process it at the end of reading.

Implements TamlCallbacks.

Reimplemented in Scene.

virtual void onTamlPostWrite ( void  )
inlineprotectedvirtual

Called after Taml has finished writing the object.

Implements TamlCallbacks.

Reimplemented in ImageAsset, AudioAsset, and SkeletonAsset.

virtual void onTamlPreRead ( void  )
inlineprotectedvirtual

Called prior to Taml reading the object.

Implements TamlCallbacks.

Reimplemented in Scene.

virtual void onTamlPreWrite ( void  )
inlineprotectedvirtual

Taml callbacks.

Implements TamlCallbacks.

Reimplemented in ImageAsset, AudioAsset, and SkeletonAsset.

void popScriptCallbackGuard ( void  )
inline
bool processArguments ( S32  argc,
const char **  argv 
)
virtual

Process constructor options. (ie, new SimObject(1,2,3))

Reimplemented in SimGroup, SimComponent, TCPObject, ConsoleLogger, and SimXMLDocument.

void processDeleteNotifies ( )

Send out deletion notifications.

void pushScriptCallbackGuard ( void  )
inline
bool readObject ( Stream stream)
virtual

Reimplemented in SimSet.

bool registerObject ( )

Register an object with the object system.

This must be called if you want to keep the object around. In the rare case that you will delete the object immediately, or don't want to be able to use Sim::findObject to locate it, then you don't need to register it.

registerObject adds the object to the global ID and name dictionaries, after first assigning it a new ID number. It calls onAdd(). If onAdd fails, it unregisters the object and returns false.

If a subclass's onAdd doesn't eventually call SimObject::onAdd(), it will cause an assertion.

bool registerObject ( U32  id)

Register the object, forcing the id.

See also
registerObject()
Parameters
idID to assign to the object.
bool registerObject ( const char *  name)

Register the object, assigning the name.

See also
registerObject()
Parameters
nameName to assign to the object.
bool registerObject ( const char *  name,
U32  id 
)

Register the object, assigning a name and ID.

See also
registerObject()
Parameters
nameName to assign to the object.
idID to assign to the object.
void registerReference ( SimObject **  obj)

Register a reference to this object.

You pass a pointer to your reference to this object.

When the object is deleted, it will null your pointer, ensuring you don't access old memory.

Parameters
objPointer to your reference to the object.
void removeFieldFilter ( const char *  fieldName)
bool removeFromSet ( SimObjectId  sid)
bool removeFromSet ( const char *  objectName)
SimObject::Notify * removeNotify ( void *  ptr,
Notify::Type  type 
)

Remove a notification from the list.

bool save ( const char *  pcFilePath,
bool  bOnlySelected = false 
)
virtual

Save object as a TorqueScript File.

void setCanSaveDynamicFields ( bool  bCanSave)
inline

Set whether fields created at runtime should be saved. Default is true.

static bool setClass ( void *  obj,
const char *  data 
)
inlinestaticprotected
void setClassNamespace ( const char *  classNamespace)
void setDataField ( StringTableEntry  slotName,
const char *  array,
const char *  value 
)

Set the value of a field on the object.

See here for a detailed discussion of what this function does.

Parameters
slotNameField to access.
arrayString containing index into array; if NULL, it is ignored.
valueValue to store.
void setExpanded ( bool  exp)
inline
void setHidden ( bool  b = true)
void setId ( SimObjectId  id)
void setInternalName ( const char *  newname)

These functions support internal naming that is not namespace bound for locating child controls in a generic way.

Set the internal name of this control (Not linked to a namespace)

void setLocked ( bool  b = true)
void setModDynamicFields ( bool  dyn)
inline
void setModStaticFields ( bool  sta)
inline
bool setParentGroup ( void *  obj,
const char *  data 
)
staticprotected
void setPeriodicTimerID ( const S32  timerID)
inline
void setPrefixedDataField ( StringTableEntry  fieldName,
const char *  array,
const char *  value 
)
void setPrefixedDynamicDataField ( StringTableEntry  fieldName,
const char *  array,
const char *  value,
const S32  fieldType = -1 
)
void setProgenitorFile ( const char *  pFile)
inline
void setSelected ( bool  sel)
inline
static bool setSuperClass ( void *  obj,
const char *  data 
)
inlinestaticprotected
void setSuperClassNamespace ( const char *  superClassNamespace)
const char * tabComplete ( const char *  prevText,
S32  baseLen,
bool  fForward 
)

Get next matching item in namespace.

This wraps a call to Namespace::tabComplete; it gets the next thing in the namespace, given a starting value and a base length of the string. See Namespace::tabComplete for details.

void unlinkNamespaces ( )
protected
void unregisterObject ( )

Unregister the object from Sim.

This performs several operations:

  • Sets the removed flag.
  • Call onRemove()
  • Clear out notifications.
  • Remove the object from...
  • Finally, cancel any pending events for this object (as it can't receive them now).
void unregisterReference ( SimObject **  obj)

Unregister a reference to this object.

Remove a reference from the list, so that it won't get nulled inappropriately.

Call this when you're done with your reference to the object, especially if you're going to free the memory. Otherwise, you may erroneously get something overwritten.

See also
registerReference
void write ( Stream stream,
U32  tabStop,
U32  flags = 0 
)
virtual

Output the TorqueScript to recreate this object.

This calls writeFields internally.

Parameters
streamStream to output to.
tabStopIndentation level for this object.
flagsIf SelectedOnly is passed here, then only objects marked as selected (using setSelected) will output themselves.

Reimplemented in GuiControl, SimSet, SimComponent, BehaviorComponent, and NameTags.

static bool writeCanSaveDynamicFields ( void *  obj,
StringTableEntry  pFieldName 
)
inlinestaticprotected
static bool writeClass ( void *  obj,
StringTableEntry  pFieldName 
)
inlinestaticprotected
bool writeField ( StringTableEntry  fieldname,
const char *  value 
)
virtual

Determine whether or not a field should be written.

Parameters
fieldnameThe name of the field being written.
valueThe value of the field.

Reimplemented in SceneObject, and SimComponent.

void writeFields ( Stream stream,
U32  tabStop 
)
virtual

Write the fields of this object in TorqueScript.

Parameters
streamStream for output.
tabStopIndentation level for the fields.

Reimplemented in NameTags.

static bool writeInternalName ( void *  obj,
StringTableEntry  pFieldName 
)
inlinestaticprotected
bool writeObject ( Stream stream)
virtual

Reimplemented in SimSet.

static bool writeParentGroup ( void *  obj,
StringTableEntry  pFieldName 
)
inlinestaticprotected
static bool writeSuperclass ( void *  obj,
StringTableEntry  pFieldName 
)
inlinestaticprotected

Friends And Related Function Documentation

friend class SimGroup
friend
friend class SimIdDictionary
friend
friend class SimManager
friend
friend class SimManagerNameDictionary
friend
friend class SimNameDictionary
friend

Member Data Documentation

bool mCanSaveFieldDictionary
protected

true if dynamic fields (added at runtime) should be saved, defaults to true

StringTableEntry mClassName
protected

Stores the class name to link script class namespaces.

SimObjectId mId
protected

Id number for this object.

StringTableEntry mIdString
protected
StringTableEntry mInternalName
protected

Stores object Internal Name.

Namespace* mNameSpace
protected
SimObject::Notify * mNotifyFreeList = NULL
staticprotected
S32 mScriptCallbackGuard
protected

Whether the object is executing a script callback.

StringTableEntry mSuperClassName
protected

Stores super class name to link script class namespaces.

U32 mTypeMask
protected

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