Within: Difference between revisions
Created page with "This method returns a list of objects (in the Interface Repository) that contain a specified Contained object. ==Syntax== Contained receiver; Environment ..." |
|||
Line 24: | Line 24: | ||
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: | 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: | ||
<pre> | |||
if (seq._length) { | if (seq._length) { | ||
long i; | long i; | ||
Line 31: | Line 31: | ||
SOMFree (seq._buffer); /* Release the sequence buffer */ | SOMFree (seq._buffer); /* Release the sequence buffer */ | ||
} | } | ||
</pre> | |||
==Original Class== | ==Original Class== |
Revision as of 04:09, 29 November 2020
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