list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

Basic Composite Structure Diagrams

A composite structure diagram is used to show how various instances of classes, called parts, are connected at run time in order to communicate with each other.

To specify composite structure, the following are the elements that need to be present in an Umple system:

  • Classes: Ordinary Umple classes, enhanced to have the items below.
  • Ports: (required for a composite structure diagram to be generated) These are special attributes used as the origin and/or destination of data to be transferred among the parts.
  • Port bindings (Connectors): These specify how data is to be transferred among the various parts of the system. They connect ports using the -> syntax. Output of one port is transferred to the input of another port.
  • Active method declarations: These run in their own thread when constructed and are needed to ensure that data is sent and received on the ports without delay.

The example below first defines two classes with ports; a third class contains instances of the first two.

Under development: Composite structure diagrams, ports and active methods are currently under development. Code generation only works in C++

See also the Wikipedia page on Composite Structure Diagrams.

Example

// Example system representing constraint-based ping-pong example
// Demonstrates the composite Structure Diagram in Umple

class Component1 {
  // Relay-Port
  public in Integer pIn1;
  public out Integer pOut1;
  pIn1 -> pOut1;


  [pIn1]
  active increment {
     pOut1(pIn1 + 1);
  }

  [pOut1]
  active logOutPort1 {
     cout << "CMP 1 : Out data = " << pOut1 << endl;
  }
  
}

class Component2 {
  public in Integer pIn2;
  public out Integer pOut2;
  pIn2 -> pOut2;

  [pIn2, pIn2 < 10]
  active stop {
       pOut2(pIn2 + 1);
  }

  [pOut2]
  active logOutPort2 {
     cout << "CMP 2 : Out data = " << pOut2 << endl;
  }
}


class Atomic {
Component1 cmp1;
Component2 cmp2;
Integer startValue;

  after constructor {
     cmp1->pIn1(startValue);
     
  }


  cmp1.pOut1 -> cmp2.pIn2;
  cmp2.pOut2 -> cmp1.pIn1;
}


      

Load the above code into UmpleOnline

 

Syntax


primitiveDefinition : primitive [name] { [[primitiveBody]]* }

portMultiplicity : [!portMultiplicity:\[[0-9]+\]]

typedPortName : [~type]? [~portName] [[portMultiplicity]]?

portDefinition : [[portClass]] | [[portDeclaration]]

// Port Connectors
portBindingDefinition :
  ( [~fromClassname] .
  )? [fromPort] ->
  ( [~toClassname] .
  )? [toPort] [[bindinHandler]]

bindinHandler : { [**code] } | ;

// Port Watchlist Definition
portWatch- :
  ( [[constraintList]] | [[comment]] | [[reqImplementation]]
  )*

// Active Method Definition
activeMethodDefinition : [[portWatch]]? [=modifier:public
    |protected
    |private]? [type]? [=activeType:atomic
    |synchronous
    |intercept]? [=active] [[activeMethodDeclarator]] [[activeMethodBody]]+

activeMethodDeclarator : [~methodName] [[parameterList]]?

//activeMethodBody : [[activeDirectionHandler]] { ( [[activeTrigger]] )* [**code] }
activeMethodBody : [[activeMethodBodyContent]] [[inverseDirectionHandler]]?

activeTrigger : [[hitchConstraint]]? [[constraintList]]? [=trigger:/] [[activeTriggerBody]] [[thenDefinition]]? [[resolveDefinition]]?

activeTriggerBody- :
  ( [[deferredList]] | [[activeTriggerDefinition]]
  )

deferredList : [ [[activeTriggerDefinition]]
  ( , [[activeTriggerDefinition]]
  )* ]

activeTriggerDefinition- : [[anonymousTriggerBody]] | [[invoke]]

thenDefinition : .then ( [[anonymousTriggerBody]]? )

resolveDefinition : .resolve ( [[anonymousTriggerBody]]? )

hitchConstraint : [=clause:after|poll] ( [timer] )

constraintList : [ [[basicConstraint]]
  ( , [[basicConstraint]]
  )* ]

basicConstraint- : [[timeConstraint]] | [[messageConstraint]] | [[constraint]]

timeConstraint : [=clause:latency|period|timeout] ( [timer] )

messageConstraint : [=clause:priority] ( [priorityValue] )

invoke :
  ( [~classname] .
  )? [name] (
  ( [parameter]
  ( , [parameter]
  )*
  )? ) ;

anonymousTriggerBody : { [**code] }