Within
This method returns a list of objects (in the Interface Repository) that contain a specified Contained object.
Syntax
Contained receiver; Environment *env; sequence <container> rc; rc = within(receiver, env);
Parameters
- receiver (Contained)
- A pointer to a Contained object for which containing objects are needed.
- env (Environment *)
- A pointer to the Environment structure for the caller.
Returns
- rc (sequence <container>)
- Returns a sequence of Container objects that contain the specified Contained object.
Remarks
The within method returns a sequence of objects within the Interface Repository that contain the specified Contained object. If the receiving object is an InterfaceDef or ModuleDef, it can only be contained by the object that defines it. Other objects can be contained by objects that define or inherit them.
If the object is global in scope, the sequence returned by within will have its _length field set to zero.
When finished using the sequence returned by this method, the client code is responsible for releasing each of the Containers in the sequence and freeing the sequence buffer. In C, this can be accomplished as follows:
if (seq._length) { long i; for (i=0; i _somFree (seq._buffer[i]); /* Release each Container obj */ SOMFree (seq._buffer); /* Release the sequence buffer */ }
Original Class
Contained
Example Code
#include <containd.h> #include <containr.h> ... Contained anObj; Environment *ev; sequence(Container) sc; long i; ... sc = Contained_within (anObj, ev); printf ("%s is contained in (or inherited by):\n", Contained__get_name (anObj, ev)); for (i=0; i printf ("\t%s\n", Contained__get_name ((Contained) sc._buffer[i], ev)); SOMObject_somFree (sc._buffer[i]); } if (sc._length) SOMFree (sc._buffer);
Related Methods
- describe