Previous topic  Top  Next topic  Print this Topic
 

Signature Statements

 

In ObjectLogic, signature-F-atoms define which methods are applicable for instances of certain classes. In particular, a signature-F-atom declares a method on a class and gives type restrictions for parameters and results. Each method may also have a cardinality restriction that provides a minimum value and a maximum value of at least how many entries have to be provided for each method and how many entries may be provided at most. These restrictions may be viewed as typing constraints. Together with the class hierarchy, signature-F-atoms form the schema of an ObjectLogic database. In general the syntax may be described as follows:

<domain>[<methodname> {<mincard>:<maxcard>} *=>  <range>].

Here are some examples for signature-F-atoms:

Person[name {1:*} *=>  xsd#string].

Person[friend {0:*} *=>  Person].

Vehicle[owner(xsd#integer) {1:1} *=>  Person].

The first one states that the method name is defined for members of the class person and the corresponding result object has to belong to the data type string. The cardinality is defined to be a minimum of 1 and a maximum of unlimited (*). The second one defines the method friend for members of the class person restricting the result objects to the class person. The cardinality is defined with a minimum of 0 and again the maximum is unlimited. Finally, the third signature-F-atom allows the application of the method owner to objects belonging to the class vehicle with parameter objects that are values of the data type integer. The result objects of such method applications will be instances of the class person. The cardinality is minimum 1 and maximum 1 as well which means it has to be exactly 1.

By using a list of result classes enclosed by parentheses, several signature-F-atoms may be combined in an F-molecule. This is equivalent to the conjunction of the atoms, i.e. the result of the method is required to be in all of those classes:

Vehicle[owner {1:*} *=>  {Person, Adult}].

is equivalent to

Vehicle[owner {1:*} *=> Person].

Vehicle[owner {1:*} *=> Adult].

ObjectLogic also supports method overloading. This means that methods denoted by the same object name may be applied to instances of different classes. Methods may even be overloaded according to their arity, i.e. number of parameters. For example, the method owner applicable to instances of the class vehicle can be used as a method without parameter or as a method with one parameter. The corresponding signature-F-atoms look like this:

Vehicle[owner {1:*} *=> Person].

Vehicle[owner(xsd#integer) {1:1} *=>  Person].