Selection Manager

From Second Life Wiki
Revision as of 13:54, 7 February 2007 by Richard Linden (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

LLHandle<Type>

LLObjectSelection LLParcelSelection

LLHandle is a special kind of reference counting pointer that can never be NULL. Whenever assigning NULL to an LLHandle, it will point to a default empty instance of the referenced object. For example:

LLHandle<LLObjectSelection> object_selection = gSelectMgr->getSelection(); llinfos << object_selection->getNumObjects() << llendl;

Prints "n" where n is the number of objects currently selected.

object_selection = NULL;

llinfos << object_selection->getNumObjects() << llendl;

Prints "0", as object_selection now points to an empty selection.

Notice that selections can only be modified and created via LLSelectMgr.

Once the number of references for a given selection drops to 1 (the only handle being the one maintained by the selection manager), the selection manager is free to deselect the corresponding objects and clean up or reuse the selection instance.

Any time you modify a given selection, you need to update your handle to point to a potentially new selection. For example:

LLHandle<LLObjectSelection> selected_objects = gSelectMgr->getSelection(); Selected_objects = gSelectMgr->addObject(selected_objects, object_ptr);

Usually, a selection will be built once (or modified by an LLTool instance) and the handle will be passed to the selection manager to perform various operations:


gSelectMgr->selectionDelete(selected_objects);