|
SimSet Class Reference
[Console, Scripting]
A collection of SimObjects. More...
Public Member Functions | |
bool | acceptsAsChild (SimObject obj) |
Test whether the given object may be added to the set. | |
void | add (SimObject objects...) |
Add the given objects to the set. | |
void | bringToFront (SimObject obj) |
Make the given object the first object in the set. | |
void | callOnChildren (string method, string args...) |
Call a method on all objects contained in the set. | |
void | callOnChildrenNoRecurse (string method, string args...) |
Call a method on all objects contained in the set. | |
void | clear () |
Remove all objects from the set. | |
void | deleteAllObjects () |
Delete all objects in the set. | |
SimObject | findObjectByInternalName (string internalName, bool searchChildren=false) |
Find an object in the set by its internal name. | |
int | getCount () |
Get the number of objects contained in the set. | |
int | getFullCount () |
Get the number of direct and indirect child objects contained in the set. | |
SimObject | getObject (int index) |
Get the object at the given index. | |
int | getObjectIndex (SimObject obj) |
Return the index of the given object in this set. | |
SimObject | getRandom () |
Return a random object from the set. | |
bool | isMember (SimObject obj) |
Test whether the given object belongs to the set. | |
void | listObjects () |
Dump a list of all objects contained in the set to the console. | |
void | pushToBack (SimObject obj) |
Make the given object the last object in the set. | |
void | remove (SimObject objects...) |
Remove the given objects from the set. | |
void | reorderChild (SimObject child1, SimObject child2) |
Make sure child1 is ordered right before child2 in the set. | |
void | sort (string callbackFunction) |
Sort the objects in the set using the given comparison function. | |
Callbacks | |
void | onObjectAdded (SimObject object) |
Called when an object is added to the set. | |
void | onObjectRemoved (SimObject object) |
Called when an object is removed from the set. |
Detailed Description
A collection 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.
Member Function Documentation
bool SimSet::acceptsAsChild | ( | SimObject | obj | ) |
Test whether the given object may be added to the set.
- Parameters:
-
obj The object to test for potential membership.
- Returns:
- True if the object may be added to the set, false otherwise.
void SimSet::add | ( | SimObject | objects... | ) |
Add the given objects to the set.
- Parameters:
-
objects The objects to add to the set.
void SimSet::bringToFront | ( | SimObject | obj | ) |
Make the given object the first object in the set.
- Parameters:
-
obj The object to bring to the frontmost position. Must be contained in the set.
void SimSet::callOnChildren | ( | string | method, | |
string | args... | |||
) |
Call a method on all objects contained in the set.
- Parameters:
-
method The name of the method to call. args The arguments to the method.
- Note:
- This method recurses into all SimSets that are children to the set.
- See also:
- callOnChildrenNoRecurse
void SimSet::callOnChildrenNoRecurse | ( | string | method, | |
string | args... | |||
) |
Call a method on all objects contained in the set.
- Parameters:
-
method The name of the method to call. args The arguments to the method.
- Note:
- This method does not recurse into child SimSets.
- See also:
- callOnChildren
void SimSet::clear | ( | ) |
Remove all objects from the set.
Reimplemented in GuiPopUpMenuCtrlEx.
void SimSet::deleteAllObjects | ( | ) |
Delete all objects in the set.
SimObject SimSet::findObjectByInternalName | ( | string | internalName, | |
bool | searchChildren = false | |||
) |
Find an object in the set by its internal name.
- Parameters:
-
internalName The internal name of the object to look for. searchChildren If true, SimSets contained in the set will be recursively searched for the object.
- Returns:
- The object with the given internal name or 0 if no match was found.
int SimSet::getCount | ( | ) |
Get the number of objects contained in the set.
- Returns:
- The number of objects contained in the set.
int SimSet::getFullCount | ( | ) |
Get the number of direct and indirect child objects contained in the set.
- Returns:
- The number of objects contained in the set as well as in other sets contained directly or indirectly in the set.
SimObject SimSet::getObject | ( | int | index | ) |
Get the object at the given index.
- Parameters:
-
index The object index.
- Returns:
- The object at the given index or -1 if index is out of range.
int SimSet::getObjectIndex | ( | SimObject | obj | ) |
Return the index of the given object in this set.
- Parameters:
-
obj The object for which to return the index. Must be contained in the set.
- Returns:
- The index of the object or -1 if the object is not contained in the set.
SimObject SimSet::getRandom | ( | ) |
Return a random object from the set.
- Returns:
- A randomly selected object from the set or -1 if the set is empty.
bool SimSet::isMember | ( | SimObject | obj | ) |
Test whether the given object belongs to the set.
- Parameters:
-
obj The object.
- Returns:
- True if the object is contained in the set; false otherwise.
void SimSet::listObjects | ( | ) |
Dump a list of all objects contained in the set to the console.
void SimSet::onObjectAdded | ( | SimObject | object | ) |
Called when an object is added to the set.
- Parameters:
-
object The object that was added.
void SimSet::onObjectRemoved | ( | SimObject | object | ) |
Called when an object is removed from the set.
- Parameters:
-
object The object that was removed.
void SimSet::pushToBack | ( | SimObject | obj | ) |
Make the given object the last object in the set.
- Parameters:
-
obj The object to bring to the last position. Must be contained in the set.
void SimSet::remove | ( | SimObject | objects... | ) |
Remove the given objects from the set.
- Parameters:
-
objects The objects to remove from the set.
Make sure child1 is ordered right before child2 in the set.
- Parameters:
-
child1 The first child. The object must already be contained in the set. child2 The second child. The object must already be contained in the set.
void SimSet::sort | ( | string | callbackFunction | ) |
Sort the objects in the set using the given comparison function.
- Parameters:
-
callbackFunction Name of a function that takes two object arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal.