SimSet Class Reference

#include <simSet.h>

Inheritance diagram for SimSet:

Inheritance graph
[legend]
List of all members.

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
void clear ()

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.
SimObjectfindObjectByInternalName (const char *internalName, bool searchChildren=false)
virtual bool writeObject (Stream *stream)
virtual bool readObject (Stream *stream)
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 ()
 It will force the object to the end of the list if it already exists in the list. 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, GuiTSCtrl, GuiBitmapButtonCtrl, GuiBitmapButtonTextCtrl, GuiButtonBaseCtrl, GuiButtonCtrl, GuiCheckBoxCtrl, GuiIconButtonCtrl, GuiRadioCtrl, GuiToggleButtonCtrl, GuiToolboxButtonCtrl, GuiAutoScrollCtrl, GuiContainer, GuiControlArrayControl, GuiDragAndDropControl, GuiDynamicCtrlArrayControl, GuiFormCtrl, GuiFrameSetCtrl, GuiPaneControl, GuiPanel, GuiRolloutCtrl, GuiScrollCtrl, GuiSplitContainer, GuiStackControl, GuiTabBookCtrl, GuiWindowCtrl, GuiBackgroundCtrl, GuiBitmapCtrl, GuiColorPickerCtrl, GuiConsole, GuiConsoleEditCtrl, GuiConsoleTextCtrl, GuiDirectoryFileListCtrl, GuiDirectoryTreeCtrl, GuiFileTreeCtrl, GuiGameListMenuCtrl, GuiGameListOptionsCtrl, GuiListBoxCtrl, GuiMLTextCtrl, GuiMLTextEditCtrl, GuiPopupTextListCtrl, GuiPopUpMenuCtrl, GuiPopupTextListCtrlEx, GuiPopUpMenuCtrlEx, GuiSliderCtrl, GuiTabPageCtrl, GuiTextCtrl, GuiTextEditCtrl, GuiTextEditSliderCtrl, GuiTextListCtrl, GuiTreeViewCtrl, GuiArrayCtrl, GuiCanvas, GuiControl, GuiScriptNotifyCtrl, DbgFileView, GuiEditCtrl, GuiFilterCtrl, GuiGraphCtrl, GuiInspector, GuiInspectorTypeEnum, GuiInspectorTypeCheckBox, GuiInspectorTypeGuiProfile, GuiInspectorTypeFileName, GuiInspectorTypeColor, GuiInspectorTypeColorI, GuiInspectorTypeColorF, GuiInspectorTypeString, GuiInspectorTypeS32, GuiMenuBackgroundCtrl, GuiSubmenuBackgroundCtrl, GuiMenuTextListCtrl, GuiMenuBar, GuiSeparatorCtrl, GuiInspectorDatablockField, GuiInspectorDynamicField, GuiInspectorDynamicGroup, GuiInspectorField, GuiInspectorGroup, GuiAviBitmapCtrl, GuiMessageVectorCtrl, GuiProgressCtrl, CreatorTree, EditManager, EditTSCtrl, GuiTerrPreviewCtrl, MissionAreaEditor, TerrainEditor, WorldEditor, GuiTheoraCtrl, GuiTickCtrl, GuiAtlasMonitorCtrl, GuiBubbleTextCtrl, GuiInputCtrl, GuiMouseEventCtrl, sgGuiTexTestCtrl, MenuBar, DInputManager, UInputManager, Path, NetConnection, AIClient, AIConnection, GameConnection, GameTSCtrl, and GuiObjectView.


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 GuiContainer, GuiStackControl, and MenuBar.

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

void SimSet::clear (  ) 

virtual void SimSet::onRemove (  )  [virtual]

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 GuiControl, TerrainEditor, DInputManager, and UInputManager.

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

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

Remove an object from the set.

Reimplemented in SimGroup, GuiContainer, GuiFrameSetCtrl, GuiRolloutCtrl, GuiStackControl, GuiControl, MenuBar, and Path.

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

Add object to end of list.

Reimplemented in MenuBar.

virtual void SimSet::popObject (  )  [virtual]

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

Reimplemented in MenuBar.

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.

SimObject* SimSet::findObjectByInternalName ( const char *  internalName,
bool  searchChildren = false 
)

virtual bool SimSet::writeObject ( Stream stream  )  [virtual]

Reimplemented from SimObject.

virtual bool SimSet::readObject ( Stream stream  )  [virtual]

Reimplemented from SimObject.

void SimSet::lock (  )  [inline]

void SimSet::unlock (  )  [inline]

SimSet::DECLARE_CONOBJECT ( SimSet   ) 


Member Data Documentation

void* SimSet::mMutex [protected]