list of dots University of Ottawa logo / Université d'Ottawa

User Manual    [Previous]   [Next]   

Require Statement

Require statements in Umple are used to specify dependencies and relationships among mixsets.

In the simplest case a require statement simply declares that certain code requires the presence of a certain mixset and that it would be an error if there is no use statement for this mixset. If the require statement is itself in a mixset, then it is stating that mixset requires the presence of one or more others. In the first code example below, the mixset M1 (Line 2) requires mixset M2 (Line 6). Mote that the specification of the required mixset M2 is in square brackets: That is because the argument to the require statement is a Boolean condition involving mixsets with logical connectors

Require statements may include the subfeature keyword to specify mixsets that are features. A require statement containing subfeature forms a parent-child relationship between the source mixset and the target mixset and both will become features.

When a mixset acts as an optional feature; the keyword isFeature can be included in the mixset body instead of using the require statement. The keyword isFeature makes a mixset an optional feature to the container mixset (the one which the former is nested in). If the mixset containing isFeature is a top entity element in an Umple file, the mixset becomes an optional feature to the SPL base.

The second code example below contains multiple features that form a feature model. Line 5 indicates that GSM1800 is required but that GSM1900 is not. Line 9 states that one or both of two sound features is required. Line 18 states that up to one of three resolution features is required (i.e. only at most one). Line 21 contains a use statement that produces a software variant with five features.

Example Showing mixset M1 requiring the presence of mixset M2

// M1 and M2 are mixsets that are not part of the feature model.
mixset M1 {
 require [M2];
}

mixset M2 { }
      

Load the above code into UmpleOnline

 

Example with various require statements that generates a feature diagram

// These require statements form a feature model. 
require subfeature [GSMProtocol opt Mp3Recording and Playback and AudioFormat opt Camera];

mixset GSMProtocol {
  require subfeature [GSM1800 opt GSM1900];
}

mixset AudioFormat {
  require subfeature [1..2 of {Mp3,Wav} ];
}
mixset Mp3Recording {
  require [Mp3];
}
mixset Camera {
  require subfeature [Resolution];
}
mixset Resolution{
  require subfeature [0..1 of {Res21MP, Res31MP, Res50MP}];
}

use GSMProtocol, GSM1800,  Playback, AudioFormat, Wav;
      

Load the above code into UmpleOnline

 

Example with isFeature statements that generates optional features

// Because Debug contains isFeature, it is an optional feature to the base SPL.

mixset Debug{
  
  isFeature;

  // Because ConsolePrint contains isFeature, it is an optional feature to Debug.
  mixset ConsolePrint
  {
    isFeature;
  }
  
}
      

Load the above code into UmpleOnline

 

Syntax


requireStatement : require ( [=subfeature] )? [[requireBody]]

requireBody- : [(([[requireLinkingOptNot]])? (()* [[requireTerminal]] [[requireList]])]

requireList- : ([[requireLinkingOp]] (()* [[requireTerminal]] ())* )*

requireLinkingOp : ([[requireLinkingOptNot]]
    | [=and:&|&&|and|,]
    | [!or:([|][|]?|or|;)]
    | [=xor:xor|XOR])

requireLinkingOptNot- : ([=opt:opt] | [=not:not] )

requireTerminal : [~targetMixsetName] | [[multiplicityTerminal]]

multiplicityTerminal- : [[multiplicity]] of { [~targetMixsetName] (, [~targetMixsetName] )* }