torque Torque Game Engine Documentation
TGE Version 1.5.2

SimSet Class Reference

#include <simBase.h>

Inheritance diagram for SimSet:

Inheritance graph
[legend]

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

typedef SimObjectList::iterator iterator
typedef SimObjectList::value_type value
SimObjectfront ()
SimObjectfirst ()
SimObjectlast ()
bool empty ()
S32 size () const
iterator begin ()
iterator end ()
value operator[] (S32 index)
iterator find (iterator first, iterator last, SimObject *obj)
virtual bool reOrder (SimObject *obj, SimObject *target=0)
SimObjectat (S32 index) const

Public Member Functions

 SimSet ()
 ~SimSet ()
virtual void onRemove ()
 Called when the object is removed from the sim.
virtual void onDeleteNotify (SimObject *object)
 Called when a SimObject is deleted.
virtual void write (Stream &stream, U32 tabStop, U32 flags=0)
 Output the TorqueScript to recreate this object.
virtual SimObjectfindObject (const char *name)
 Find a named sub-object of this object.
void lock ()
void unlock ()
 DECLARE_CONOBJECT (SimSet)
Set Management
virtual void addObject (SimObject *)
 Add an object to the set.
virtual void removeObject (SimObject *)
 Remove an object from the set.
virtual void pushObject (SimObject *)
 Add object to end of list.
virtual void popObject ()
 Remove an object from the end of the list.
void bringObjectToFront (SimObject *obj)
void pushObjectToBack (SimObject *obj)

Protected Attributes

SimObjectList objectList
voidmMutex

Private Types

typedef SimObject Parent


Member Typedef Documentation

typedef SimObject SimSet::Parent [private]

Reimplemented from SimObject.

Reimplemented in SimGroup, SimChunk, UnknownChunk, CreatorTree, EditManager, EditTSCtrl, GuiTerrPreviewCtrl, MissionAreaEditor, TerrainEditor, WorldEditor, AIClient, AIConnection, DebugView, GameConnection, GameTSCtrl, GuiPlayerView, GuiControlArrayControl, GuiFrameSetCtrl, GuiPaneControl, GuiScrollCtrl, GuiStackControl, GuiTabBookCtrl, GuiWindowCtrl, GuiBackgroundCtrl, GuiBitmapButtonCtrl, GuiBitmapButtonTextCtrl, GuiBitmapCtrl, GuiButtonBaseCtrl, GuiButtonCtrl, GuiCheckBoxCtrl, GuiColorPickerCtrl, GuiConsole, GuiConsoleEditCtrl, GuiConsoleTextCtrl, GuiDirectoryFileListCtrl, GuiDirectoryTreeCtrl, GuiListBoxCtrl, GuiMLTextCtrl, GuiMLTextEditCtrl, GuiPopUpTextListCtrl, GuiPopUpMenuCtrl, GuiRadioCtrl, GuiSliderCtrl, GuiTabPageCtrl, GuiTextCtrl, GuiTextEditCtrl, GuiTextEditSliderCtrl, GuiTextListCtrl, GuiTreeViewCtrl, GuiArrayCtrl, GuiCanvas, GuiControl, GuiTSCtrl, DbgFileView, GuiEditCtrl, GuiFilterCtrl, GuiGraphCtrl, GuiInspector, GuiInspectorField, GuiInspectorGroup, GuiInspectorDynamicField, GuiInspectorDynamicGroup, GuiInspectorDatablockField, GuiInspectorTypeEnum, GuiInspectorTypeCheckBox, GuiInspectorTypeGuiProfile, GuiInspectorTypeFileName, GuiInspectorTypeColor, GuiInspectorTypeColorI, GuiInspectorTypeColorF, GuiMenuBackgroundCtrl, GuiSubmenuBackgroundCtrl, GuiMenuTextListCtrl, GuiMenuBar, GuiAviBitmapCtrl, GuiMessageVectorCtrl, GuiProgressCtrl, GuiEffectCanvas, GuiTheoraCtrl, GuiTickCtrl, GuiBubbleTextCtrl, GuiInputCtrl, GuiMouseEventCtrl, GuiVectorFieldCtrl, DInputManager, UInputManager, NetConnection, and Path.


Constructor & Destructor Documentation

SimSet::SimSet (  )  [inline]

SimSet::~SimSet (  )  [inline]


Member Function Documentation

SimObject* SimSet::front (  )  [inline]

SimObject* SimSet::first (  )  [inline]

SimObject* SimSet::last (  )  [inline]

bool SimSet::empty (  )  [inline]

S32 SimSet::size (  )  const [inline]

iterator SimSet::begin (  )  [inline]

iterator SimSet::end (  )  [inline]

value SimSet::operator[] ( S32  index  )  [inline]

iterator SimSet::find ( iterator  first,
iterator  last,
SimObject obj 
) [inline]

virtual bool SimSet::reOrder ( SimObject obj,
SimObject target = 0 
) [virtual]

Reimplemented in GuiStackControl.

SimObject* SimSet::at ( S32  index  )  const [inline]

virtual void SimSet::onRemove (  )  [virtual]

Called when the object is removed from the sim.

Reimplemented from SimObject.

Reimplemented in SimGroup, GameConnection, GuiTabBookCtrl, GuiTextListCtrl, GuiControl, GuiMessageVectorCtrl, GuiVectorFieldCtrl, DInputManager, UInputManager, NetConnection, and Path.

virtual void SimSet::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 from SimObject.

Reimplemented in TerrainEditor, DInputManager, and UInputManager.

virtual void SimSet::addObject ( SimObject  )  [virtual]

Add an object to the set.

Reimplemented in SimGroup, GuiFrameSetCtrl, GuiScrollCtrl, GuiStackControl, GuiControl, and Path.

virtual void SimSet::removeObject ( SimObject  )  [virtual]

Remove an object from the set.

Reimplemented in SimGroup, GuiFrameSetCtrl, GuiStackControl, GuiControl, and Path.

virtual void SimSet::pushObject ( SimObject  )  [virtual]

Add object to end of list.

It will force the object to the end of the list if it already exists in the list.

virtual void SimSet::popObject (  )  [virtual]

Remove an object from the end of the list.

void SimSet::bringObjectToFront ( SimObject obj  )  [inline]

void SimSet::pushObjectToBack ( SimObject obj  )  [inline]

virtual void SimSet::write ( Stream stream,
U32  tabStop,
U32  flags = 0 
) [virtual]

Output the TorqueScript to recreate this object.

This calls writeFields internally.

Parameters:
stream Stream to output to.
tabStop Indentation level for this object.
flags If SelectedOnly is passed here, then only objects marked as selected (using setSelected) will output themselves.

Reimplemented from SimObject.

Reimplemented in GuiControl.

virtual SimObject* SimSet::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 from SimObject.

Reimplemented in SimGroup.

void SimSet::lock (  )  [inline]

void SimSet::unlock (  )  [inline]

SimSet::DECLARE_CONOBJECT ( SimSet   ) 


Field Documentation

void* SimSet::mMutex [protected]




All Rights Reserved GarageGames.com, Inc. 1999-2005
Auto-magically Generated with Doxygen