Overview
The RoseBackptrCursor class enables an application to iterate over a set of backpointers, possibly limiting the search to a particular attribute. Thus, it provides an efficient way to compute inverse attributes or USEDIN() constructs. See Backpointers for more information.
The following example uses backpointers to find the product_definition_formation instances associated with a product.
RoseObject * product; RoseAttribute * att = des->findDomain(product_definition_formation) ->findTypeAttribute(of_product); RoseBackPtrCursor cur; RoseObject *pdf; cur.traverse(product); cur.attribute(att); while (pdf = cur.next()) { /* Do somethig with the product_definition_formation in pd */ }
attribute
void attribute( RoseAttribute *att );
The attribute() function declares the inverted attribute to which the scope of the inverse search is limited.
fastforward
void fastforward();
The fastforward() function sets the current pointer after the last object so that the next call to previous() will return the last backpointer.
first
RoseStructure * first();
The first() function rewinds the iterator and returns the first object in the backpointer list.
last
RoseStructure * last();
The last() function fastworwards the iterator and returns the last object in the backpointer list.
next
RoseStructure * next();
The next() function returns the next object in the backpointer list, and advances the iterator.
previous
RoseStructure * previous();
The previous() function returns the previous object in the backpointer list, and decreases the iterator.
rewind
void rewind()
The rewind() function sets the cursor so that the next call will return the first object in the list.
traverse
void traverse( RoseObject * obj );
The traverse() function determines the RoseObject that will be searched for backpointers.