Jump to content

Contents

From EDM2
Revision as of 04:38, 29 November 2020 by Martini (talk | contribs)

This method returns a sequence indicating the objects contained within a specified Container object of the Interface Repository.

Syntax

  
Container              receiver;
Environment           *env;
InterfaceName          limit_type;
boolean                exclude_inherited;
sequence<Contained>    rc;

rc = contents(receiver, env, limit_type, exclude_inherited);

Parameters

receiver (Container)
A pointer to a Container object whose contained objects are needed.
env (Environment *)
A pointer to the Environment structure for the caller.
limit_type (InterfaceName)
The name of one interface type (see the valid list above) or "all", to specify what type of objects the contents method should search for.
exclude_inherited (boolean)
A boolean value: TRUE to exclude any inherited objects, or FALSE to include all objects.

Returns

rc (sequence<Contained>)
Returns a sequence of pointers to objects contained within the specified Container object.

Remarks

The contents method returns a list of objects contained by the specified Container object. Each object represents a component of an IDL interface (class) definition maintained within the Interface Repository.

The contents method is used to navigate through the hierarchy of objects within the Interface Repository. Starting with the Repository object, this method can list all of the objects in the Repository, then all of the objects within the ModuleDef objects, then all within the InterfaceDef objects, and so on.

If the "limit_type" is set to "all", objects of all interface types are returned; otherwise, only objects of the requested interface type are returned. Valid values for InterfaceName are limited to the following set: {"AttributeDef", "ConstantDef", "ExceptionDef", "InterfaceDef", "ModuleDef", "ParameterDef", "OperationDef", "TypeDef", "all"}

If "exclude_inherited" is set to TRUE, any inherited objects will not be returned.

When finished using the sequence returned by this method, the client code is responsible for releasing each of the objects 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 <seq._length;i++)
       SOMObject_somFree (seq._buffer[i]); /* Release each object */
    SOMFree (seq._buffer);                 /* Release the buffer  */
}

Original Class

Container

Example Code

 
#include <containr.h>

...

Container anObj;
Environment *ev;
sequence(Contained) sc;
long i;

...

sc = Container_contents (anObj, ev, "all", TRUE);
printf ("%s contains the following objects:\n",
    SOMObject_somIsA (anObj, _Contained) ?
        Contained__get_name ((Contained) anObj, ev) :
        "The Interface Repository");
for (i=0; i <seq._length;i++) {
    printf ("\t%s\n",
        Contained__get_name (sc._buffer[i], ev));
    SOMObject_somFree (sc._buffer[i]);
}
if (sc._length)
    SOMFree (sc._buffer);
else
    printf ("\t[none]\n");

Related Methods