Jump to content

Lookup id

From EDM2
Revision as of 22:18, 7 November 2021 by Ak120 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This method locates an object by name within a specified Container object of the Interface Repository, or within objects contained in the Container object.

Syntax

Container              receiver;
Environment           *env;
Identifier             search_name;
long                   levels_to_search;
InterfaceName          limit_type;
boolean                exclude_inherited;
sequence<Contained>    rc;

rc = lookup_name(receiver, env, search_name, levels_to_search, limit_type, exclude_inherited);

Parameters

receiver (Container)
A pointer to a Container object in which to locate the object.
env (Environment *)
A pointer to the Environment structure for the caller.
search_name (Identifier)
The name of the object to be located.
levels_to_search (long)
A long having the value 1 or -1.
limit_type (InterfaceName)
The name of one interface type (see the valid list above) or "all", to specify what type of object to search for.
exclude_inherited (boolean)
A boolean value: TRUE to exclude an object when it is inherited, or FALSE to return the object from wherever it is found.

Returns

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

Remarks

The lookup_name method locates an object by name within a specified Container object, or within objects contained in the Container object. The "search_name" specifies the name of the object to be found. Each object represents a component of an IDL interface (class) definition maintained within the Interface Repository.

The "levels_to_search" argument controls whether the lookup is constrained to the specified Container object or whether objects contained within the Container object are also searched. The "levels_to_search" value should be -1 to search the Container and all contained objects; it should be 1 to search only the Container itself.

If "limit_type" is set to "all", the lookup locates an object of the specified name with any interface type; otherwise, the search locates the object only if it has the designated interface type. 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>
#include <containd.h>
#include <repostry.h>

...

Container repo;
Environment *ev;
sequence(Contained) sc;
long i;
Identifier nameToFind;

...

repo = (Container) RepositoryNew ();
sc = Container_lookup_name (repo, ev, nameToFind, -1, "all", TRUE);
printf ("%d object%s found:\n",
          sc._length, sc._length == 1 ? "" : "s");
for (i=0; i <seq._length;i++) {
    printf ("\t%s\n",
        Contained__get_id (sc._buffer[i], ev));
    SOMObject_somFree (sc._buffer[i]);
}
if (sc._length)
    SOMFree (sc._buffer);

Related Methods