Overview

The RoseTypesCursor class is a RoseCursor subtype that traverses a list of types rather than just a single type. This can be more efficent than several traversals because you are guaranteed to see a matching object only once, even if the object matches more than one type.

Instead of specifying one type with domain() or exact(), you specify many types with addDomain() or addExact(). In all other ways, the RoseTypesCursor class is used the same way as the RoseCursor class.

RoseTypesCursor objs;
RoseObject * obj;

objs.traverse (design);
objs.addDomain (ROSE_DOMAIN(some_type));
objs.addDomain (ROSE_DOMAIN(another_type));
objs.addDomain (ROSE_DOMAIN(a_third_type));

while ((obj=objs.next()) != 0) {

      // do something with each object
}

addDomain()

void addDomain(
	RoseDomain * domain
 	);

The addDomain() function adds a domain to the range of object types that will be returned by the traversal. The cursor returns instances of the type or any subtypes.

Changing the type of objects targeted by the cursor, either with this function, addExact(), or addSelectRange() will reset the cursor back to the start as if rewind() was called.

addExact()

void addExact(
	RoseDomain * domain
 	);

The addExact() function adds a domain to the range of object types that will be returned by the traversal. Objects are only returned if they are exactly this type. No subtypes will be included.

Calling addExact() switches the entire list of types to "exact", even types added using addDomain(). Calling resetDomains() will change the cursor back to returning types and subtypes.

Changing the type of objects targeted by the cursor, either with this function, addDomain(), or addSelectRange() will reset the cursor back to the start as if rewind() was called.

addSelectRange()

void addSelectRange(
	RoseDomain * domain
 	);

The addSelectRange() function adds all of the undelying object types that can appear in an EXPRESS select type. The range of nested selects are recursively added.

Changing the type of objects targeted by the cursor, either with this function, addDomain(), or addExact() will reset the cursor back to the start as if rewind() was called.

isExact()

int isExact();

The isExact() function returns true if the list of types is compared to exact types (addExact() was used), or false if the list will also match subtypes.

resetDomains()

void resetDomains(); 

The resetDomains() function empties the list of types that are matched by the cursor.

types()

ListOfRoseDomain * types();

The types() function returns the list of types that are matched by the cursor.