related_to function

Phil Spiby Phil.Spiby at eurostep.com
Sat Nov 30 11:29:38 EST 2002


Günter & others,

The related_to function was originally specified in the E2 which became
E3.
The spec is as follows (cut from the latest E3 document and converted
the 
ROLENAME datatypes into STRINGS!):


Related_To - general function
FUNCTION related_to (s_role:STRING; source:GENERIC_ENTITY;
t_role:STRING): BAG OF GENERIC;

The related_to function returns the bag of values which play the role 
t_role in instances in which the source plays the role s_role.

Parameters
s_role is the name of an attribute in a particular entity datatype.
source is a value which may play the role s_role in instances of type
Association.
t_role is the name of an attribute in the same entity datatype as
s_role

Result
The bag of values used as attribute t_role in the instances in which
source plays the role s_role.
If either t_role or s_role are empty strings the result is an empty bag.
If source indeterminate the result is an empty bag.

Example
This example shows how the marriage relationship may be traversed to 
obtain information about the partners in marriages.
  ENTITY male;
    ...
  END_ENTITY;

  ENTITY female;
    ...
  END_ENTITY;

  ENTITY marriage;
    husband : male;
    wife : female:
    date_of_marriage : date;
    date_of_divorce : OPTIONAL date;
  END_ENTITY;

  ...
  LOCAL
    john : male := male();
    jane : female := female();
    bob : male := male();
    m1 : marriage := marriage(john, jane, date(1,4,1989),
date(2,4,1990));
    m2 : marriage := marriage(bob, jane, date(3,4,1990), ?);
    janes_husbands : BAG OF male;
  END_LOCAL;
    janes_husbands := related_to('MYSCHEMA.MARRIAGE.WIFE', jane,
'MYSCHEMA.MARRIAGE.HUSBAND');
      -- would return _bag_of_male::[john, bob]


In answer to the questions regarding can this be done in another way,
the answer is yes but you have to write a separate function for each
attribute t_role which you want to test! This function was developed as
an extension to the USEDIN function. It was aimed at solving the problem
that each structure which is required to be acyclic requires the users
to write a specific function checking this, using the related_to
function would allow a single generic acyclic function to be written,
which could be used where-ever required by just specifying the
attributes as strings in the appropriate where-rule.

Phil

> -----Original Message-----
> From: owner-wg11 at steptools.com 
> [mailto:owner-wg11 at steptools.com] On Behalf Of Günter Staub
> Sent: 28 November 2002 20:21
> To: rob.bodington at eurostep.com; wg11 at steptools.com; 'STEP Mod 
> exploder'
> Cc: 'Phil Spiby'
> Subject: RE: related_to function
> 
> 
> Rob, et al
> 
> is there any spec of that function (input parameters, output 
> parameters, intended behaviour) beside its name?
> 
> 
> Rgds,
> Günter
> 
> 
>   
> -----Original Message-----
> From: owner-wg11 at steptools.com 
> [mailto:owner-wg11 at steptools.com] On Behalf Of > Rob Bodington
> 
> Sent: Wednesday, November 27, 2002 7:04 PM
> To: wg11 at steptools.com; STEP Mod exploder
> Cc: Phil Spiby
> Subject: related_to function
> 
> Hi
> I understand from Phil Spiby that the “related_to” function 
> originally specified in Express edition 3 was intended to be 
> included in Express ed2. It that still the case?
>  
> Regards
> Rob
> -------------------------------------------
> Rob Bodington
> Eurostep Limited
> Web Page:   http://www.eurostep.com http://www.share-a-space.com
> Email:  Rob.Bodington at eurostep.com
> Phone:  +44 (0)1454 270030
> Mobile: +44 (0)7796 176 401
> Fax:    +44 (0)1454 270031  
>  
> 




More information about the wg11 mailing list