Anders Riggelsen

Object Selection Framework

This class will help you a lot when writing extensions that manipulates the SOL.

This framework is based loosely on the sourcecodes of the Select Object by Dynasoft.

void SelectAll(short Oi);

- Resets the SOL by reselecting all objects

void SelectNone(short Oi);

- Resets the SOL, not selecting any objects

void SelectOneObject(LPRO object);

- Resets the SOL and inserts one given object into it

void SelectObjects(short Oi, LPRO* objects, int count);

- Resets the SOL and selects the given list of objects

bool ObjectIsOfType(LPRO object, short Oi);

- Returns true if the object is of the type (checks for qualifiers as well)

int GetNumberOfSelected(short Oi);

- Returns the number of selected objects for the given object type or qualifier.

bool FilterObjects(LPRDATA rdPtr, short Oi, bool negate, bool (*filterFunction)(LPRDATA, LPRO));

- Runs a custom filter on the current SOL, removing objects that fails the callback test.
Returns a boolean if the event should run (already inverted by the negate flag for convenience)

Sample condition with callback filter

//Should it select the given object?
bool sampleFilter(LPRDATA rdPtr, LPRO object)
	return (rdPtr->objectA == object || rdPtr->objectB == object);

long WINAPI DLLExport con_IsObjectRemembered(LPRDATA rdPtr, long param1, long param2)
	//Initialize the object selection framework
	ObjectSelection select = ObjectSelection(rdPtr->rHo.hoAdRunHeader);

	//Gets a pointer to the event information structure and find out if the condition is negated
	PEVT pe = (PEVT)(((LPBYTE)param1)-CND_SIZE);
	bool isNegated = (pe->evtFlags2 & EVFLAG2_NOT);
	short oi = ((eventParam*)param1)->evp.evpW.evpW0;

	//Runs the "sampleFilter" callback on any object in the SOL.
	return select.FilterObjects(rdPtr, oi, isNegated, &sampleFilter);


ObjectSelection.cpp - ObjectSelection.h