SimSet

Engine/source/console/simSet.h

A set of SimObjects.

More...

STL Interface

bool
find(iterator first, iterator last, SimObject * obj)
bool
reOrder(SimObject * obj, SimObject * target)

Reorder the position of "obj" to either be the last object in the list or, if "target" is given, to come before "target" in the list of children.

at(S32 index)

Return the object at the given index.

Remove all objects from this set.

Callbacks

DECLARE_CALLBACK(void , onObjectAdded , (SimObject *object) )
DECLARE_CALLBACK(void , onObjectRemoved , (SimObject *object) )

Set Management

addObject(SimObject * object)

Add the given object to the set.

Remove the given object from the set.

Add the given object to the end of the object list of this set.

bool

Return true if this set accepts the given object as a child.

Deletes all the objects in the set.

Remove an object from the end of the list.

scriptSort(const String & scriptCallbackFn)

Performs a sort of the objects in the set using a script callback function to do the comparison.

Public Types

enum
SetModification {
  SetCleared 
  SetObjectAdded 
  SetObjectRemoved 
}
Children 
Parent 
Signal< void(SetModification modification, SimSet *set, SimObject *object) >
SetModificationSignal 

Signal for letting observers know when objects are added to or removed from the set.

Protected Attributes

Signal that is triggered when objects are added or removed from the set.

Public Functions

addTamlChild(SimObject * pSimObject)

Called when Taml attempts to populate an objects children during a read.

callOnChildren(const String & method, S32 argc, ConsoleValueRef argv, bool executeOnChildGroups)

Return a shallow copy of this object.

findObject(const char * name)

Find a named sub-object of this object.

Find the given object in this set.

findObjectByCallback(bool(*)(T *) fn, Vector< T * > & foundObjects)

Add all child objects ( including children of children ) to the foundObjects Vector which are of type T and for which DecideAddObjectCallback return true;

findObjectByInternalName(StringTableEntry internalName, bool searchChildren)
findObjectByLineNumber(const char * fileName, S32 declarationLine, bool searchChildren)
findObjectByType(Vector< T * > & foundObjects)

Add all child objects ( including children of children ) to the foundObjects Vector which are of type T.

Return the signal that is triggered when an object is added to or removed from the set.

getTamlChild(const U32 childIndex)

Called when Taml attempts to compile a list of children.

Called when Taml attempts to compile a list of children.

Called when a SimObject is deleted.

Called when the object is removed from the sim.

bool
readObject(Stream * stream)

Return the number of objects in this set as well as all sets that are contained in this set and its children.

write(Stream & stream, U32 tabStop, U32 flags)

Output the TorqueScript to recreate this object.

bool
writeObject(Stream * stream)

Detailed Description

A set of SimObjects.

It is often necessary to keep track of an arbitrary set of SimObjects. For instance, Torque's networking code needs to not only keep track of the set of objects which need to be ghosted, but also the set of objects which must always be ghosted. It does this by working with two sets. The first of these is the RootGroup (which is actually a SimGroup) and the second is the GhostAlwaysSet, which contains objects which must always be ghosted to the client.

Some general notes on SimSets:

  • Membership is not exclusive. A SimObject may be a member of multiple SimSets.

  • A SimSet does not destroy subobjects when it is destroyed.

  • A SimSet may hold an arbitrary number of objects.

Using SimSets, the code to work with these two sets becomes relatively straightforward:

// (Example from netObject.cc)
// To iterate over all the objects in the Sim:
for (SimSetIterator obj(Sim::getRootGroup()); *obj; ++obj)
{
          NetObject* nobj = dynamic_cast<NetObject*>(*obj);

         if (nobj)
           {
             // ... do things ...
         }
 }

 // (Example from netGhost.cc)
 // To iterate over the ghostAlways set.
 SimSet* ghostAlwaysSet = Sim::getGhostAlwaysSet();
 SimSet::iterator i;

 U32 sz = ghostAlwaysSet->size();
 S32 j;

 for(i = ghostAlwaysSet->begin(); i != ghostAlwaysSet->end(); i++)
 {
     NetObject *obj = (NetObject *)(*i);

     /// ... do things with obj...
 }

STL Interface

front()

first()

last()

empty()

size()

begin()

end()

operator[](S32 index)

find(iterator first, iterator last, SimObject * obj)

find(SimObject * obj)

reOrder(SimObject * obj, SimObject * target)

Reorder the position of "obj" to either be the last object in the list or, if "target" is given, to come before "target" in the list of children.

Reimplemented by: GuiContainer, GuiTabBookCtrl, GuiControlArrayControl, GuiStackControl

at(S32 index)

Return the object at the given index.

clear()

Remove all objects from this set.

Reimplemented by: SimGroup, Forest, GuiPopUpMenuCtrl, GuiPopUpMenuCtrlEx, GuiTextListCtrl, DbgFileView, CreatorTree, VPath

typedef SimObjectList::iterator iterator 
typedef SimObjectList::value_type value 

Callbacks

DECLARE_CALLBACK(void , onObjectAdded , (SimObject *object) )

DECLARE_CALLBACK(void , onObjectRemoved , (SimObject *object) )

Set Management

addObject(SimObject * object)

Add the given object to the set.

Parameters:

object

Object to add to the set.

Reimplemented by: SimPersistSet, ForestBrush, WorldEditorSelection, SimPath::Path, GuiContainer, GuiControlArrayControl, GuiDynamicCtrlArrayControl, GuiFrameSetCtrl, GuiRolloutCtrl, GuiScrollCtrl, GuiStackControl, GuiControl, SimGroup, GuiFormCtrl, GuiMenuBar, Scene

removeObject(SimObject * object)

Remove the given object from the set.

Parameters:

object

Object to remove from the set.

Reimplemented by: WorldEditorSelection, SimPath::Path, GuiContainer, GuiControlArrayControl, GuiFrameSetCtrl, GuiRolloutCtrl, GuiStackControl, GuiControl, SimGroup, GuiFormCtrl, Scene

pushObject(SimObject * object)

Add the given object to the end of the object list of this set.

Parameters:

object

Object to add to the set.

Reimplemented by: SimGroup

acceptsAsChild(SimObject * object)

Return true if this set accepts the given object as a child.

This method should be overridden for set classes that restrict membership.

Reimplemented by: GuiFormCtrl, GuiTabBookCtrl, GuiControl

deleteAllObjects()

Deletes all the objects in the set.

popObject()

Remove an object from the end of the list.

Reimplemented by: SimGroup

bringObjectToFront(SimObject * obj)

pushObjectToBack(SimObject * obj)

scriptSort(const String & scriptCallbackFn)

Performs a sort of the objects in the set using a script callback function to do the comparison.

An example script sort callback:

function sortByName( %object1, %object2 )
{
   return strcmp( %object1.getName(), %object2.getName() );
}

Note: You should never modify the SimSet itself while in the sort callback function as it can cause a deadlock.

Public Types

SetModification

Enumerator

SetCleared
SetObjectAdded
SetObjectRemoved
typedef SimObject Children 
typedef SimObject Parent 
typedef Signal< void(SetModification modification, SimSet *set, SimObject *object) > SetModificationSignal 

Signal for letting observers know when objects are added to or removed from the set.

Parameters:

modification

In what way the set has been modified.

set

The set that has been modified.

object

If #modification is SetObjectAdded or SetObjectRemoved, this is the object that has been added or removed. Otherwise NULL.

Protected Attributes

void * mMutex 
SimObjectList mObjectList 
SetModificationSignal mSetModificationSignal 

Signal that is triggered when objects are added or removed from the set.

Public Functions

SimSet()

~SimSet()

addTamlChild(SimObject * pSimObject)

Reimplemented from: TamlChildren

callOnChildren(const String & method, S32 argc, ConsoleValueRef argv, bool executeOnChildGroups)

clone()

Reimplemented from: SimObject

Reimplemented by: SimGroup

DECLARE_CONOBJECT(SimSet )

findObject(const char * name)

Reimplemented from: SimObject

Reimplemented by: SimGroup

findObject(SimObject * object)

Find the given object in this set.

Returns NULL if the object is not part of this set.

findObjectByCallback(bool(*)(T *) fn, Vector< T * > & foundObjects)

Add all child objects ( including children of children ) to the foundObjects Vector which are of type T and for which DecideAddObjectCallback return true;

findObjectByInternalName(StringTableEntry internalName, bool searchChildren)

findObjectByLineNumber(const char * fileName, S32 declarationLine, bool searchChildren)

findObjectByType(Vector< T * > & foundObjects)

Add all child objects ( including children of children ) to the foundObjects Vector which are of type T.

getRandom()

getSetModificationSignal()

getSetModificationSignal()

Return the signal that is triggered when an object is added to or removed from the set.

getTamlChild(const U32 childIndex)

Reimplemented from: TamlChildren

getTamlChildCount(void )

Reimplemented from: TamlChildren

lock()

onDeleteNotify(SimObject * object)

Reimplemented from: SimObject

Reimplemented by: afxChoreographer, afxMagicMissile, afxMagicSpell, afxSpellButton, afxStatusBar, Item, ShapeBase, Trigger, afxCamera, afxResidueMgr, Camera, ForestWindEmitter, Gui3DProjectionCtrl, GuiControl, GuiInspector, TerrainEditor, NavPath, DInputManager, UInputManager, SceneObject, SFXSound, SFXSource, VPath

onRemove()

Reimplemented from: SimObject

Reimplemented by: afxCamera, afxChoreographer, afxMagicMissile, afxMagicSpell, afxSelectron, afxSpellBook, afxBillboard, afxModel, afxMooring, afxParticleEmitter, afxParticleEmitterPath, afxProjectile, afxZodiacPlane, afxParticlePool, ScriptGroup, SimGroup, BasicClouds, CloudLayer, DecalRoad, MeshRoad, River, ScatterSky, SkyBox, Sun, TimeOfDay, VolumetricFog, VolumetricFogRTManager, WaterBlock, WaterObject, WaterPlane, Forest, ForestWindEmitter, GuiTextListCtrl, GuiCanvas, GuiControl, GuiOffscreenCanvas, GuiEditCtrl, GuiInspector, GuiMenuBar, GuiMessageVectorCtrl, EditTSCtrl, GuiConvexEditorCtrl, CoverPoint, NavMesh, NavPath, OpenVROverlay, OpenVRTrackedObject, DInputManager, UInputManager, PostEffect, SceneObject, SceneSpace, SimPath::Path, Marker, SceneRootZone, SFXSound, SFXSource, NetConnection, NetObject, AccumulationVolume, AIPlayer, Camera, ConvexShape, Debris, RenderMeshExample, RenderObjectExample, RenderShapeExample, Explosion, fxFoliageReplicator, fxShapeReplicator, GroundCover, Lightning, ParticleEmitter, ParticleEmitterNode, Precipitation, Ribbon, RibbonNode, Splash, GameBase, GameConnection, GroundPlane, Item, LevelInfo, LightBase, BoxEnvironmentProbe, ReflectionProbe, Skylight, SphereEnvironmentProbe, MissionArea, MissionMarker, CameraBookmark, NotesObject, PathCamera, PathShape, PhysicalZone, PhysicsDebris, PhysicsForce, PhysicsShape, Player, Prefab, Projectile, ProximityMine, RigidShape, Scene, SFXEmitter, ShapeBase, StaticShape, Trigger, TSStatic, AITurretShape, TurretShape, FlyingVehicle, HoverVehicle, Vehicle, VehicleBlocker, WheeledVehicle, TerrainBlock, VActor, VPath

readObject(Stream * stream)

Reimplemented from: SimObject

sizeRecursive()

Return the number of objects in this set as well as all sets that are contained in this set and its children.

note:

The child sets themselves count towards the total too.

unlock()

write(Stream & stream, U32 tabStop, U32 flags)

Reimplemented from: SimObject

Reimplemented by: GuiControl, NavMesh, SimPersistSet

writeObject(Stream * stream)

Reimplemented from: SimObject