# Interfaces

An interface model (stored in a file with extension '.interface') defines the interface behavior and starts by importing the interface signature. The interface name has to be the same as the name given in the signature definition. Next, the interface model may optionally contain global variables and their initial values. The model then defines a number of state machines.

## General Structure of Interface Definition

The following is an example of the general structure, where the file "interfaceSignature.signature" contains the signature:

    import "interfaceSignature.signature"

interface declaration with name, optional version, and optional indicator for singleton interface:

    singleton interface interfaceName version "1.0"  //version is optional

    variables

    bool aGlobalVariable
    bool error
    int code

    init
    aGlobalVariable := true
    error := false
    code := 0

    event fragments

optional event fragment definitions

    machine first {

States and transitions

    }

    machine second {

States, and transitions

    }

The sets of events used in the state machines (commands, signals, notifications) must be disjoint. Nested state machines are not supported.

Optionally, a number of constraints can be specified. Constraints can be:

timing constraints

Timing constraints

data constraints

Data constraints

generic constraints

Generic constraints

## Singleton and Multiton Interfaces

A CommaSuite interface is either singleton or multiton. The difference concerns the way an interface is provided to its clients.

When a multiton interface is provided to clients, every client uses a separate instance of the interface. When a singleton interface is provided to clients, all the clients share the same instance of the interface.

By default an interface is defined as multiton. The definition of a singleton interface requires a keyword to be explicitly given:

    interface interfaceName //by default the interface is multiton

    singleton interface interfaceName //a singleton interface requires an explicit indication in the definition

The multiton/singleton dichotomy has an impact on the interface monitoring process.