blob: 2694c5091b03d3daf349057291c556ce957803eb [file] [log] [blame]
[comment encoding = UTF-8 /]
[comment
-----------------------------------------------------------------------
-- Ada infrastructural code generator --
-- for the CHESS component model --
-- --
-- Copyright (C) 2011-2012 --
-- University of Padova, ITALY --
-- --
-- Author: Marco Panunzio panunzio@math.unipd.it --
-- --
-- All rights reserved. This program and the accompanying materials --
-- are made available under the terms of the Eclipse Public License --
-- v1.0 which accompanies this distribution, and is available at --
-- http://www.eclipse.org/legal/epl-v20.html --
-----------------------------------------------------------------------
/]
[module Interface('http://www.eclipse.org/uml2/3.0.0/UML')]
[import org::polarsys::chess::codegen::ada::main::Copyright /]
[template public generateInterface(model: Model, procNode : InstanceSpecification, aInterface : Interface) {
datatypeWithRequired : Boolean = isDataTypeWithRequired(aInterface);
procNodeName : String = procNode.name
}]
[file (procNodeName.concat('/src/interface/').concat(aInterface.name).concat('.ads').toLower(), false, 'UTF-8')]
[generateCopyrightAda(model)/]
-- UNIT Name : Interface [aInterface.name/]
-- generated from : [aInterface.qualifiedName/]
--
-- Contained Units :
[for (op : Operation | aInterface.ownedOperation)]
-- procedure [op.name/]
[/for]
--
-- Description:
[getDocumentation(aInterface)/]
-- Comment the with below if you do not use user-defined datatypes
with Datatype; use Datatype;
package [aInterface.name/] is
type [aInterface.name/] is interface;
[for (op : Operation | aInterface.ownedOperation)]
[if (isFunction(op))]
-- Module Name : function [op.name/]
[else]
-- Module Name : procedure [op.name/]
[/if]
-- generated from : [op.qualifiedName/]
--
-- Description: [getDocumentation(op)/]
--
[if (isFunction(op))]
[if (op.ownedParameter->size() = 1)]
function [op.name/] (Self : in out [aInterface.name/]) return [getReturnParam(op).type.name/] is abstract;
[else]
function [op.name/] (Self : in out [aInterface.name/] [for (par : Parameter | op.ownedParameter)][if(not par.direction.toString().equalsIgnoreCase('return'))];
[par.name/] : [par.direction/] [par.type.name/][/if][/for]) return [getReturnParam(op).type.name/] is abstract;
[/if]
[else]
[if (op.ownedParameter->size() = 0)]
procedure [op.name/] (Self : in out [aInterface.name/]) is abstract;
[else]
procedure [op.name/] (Self : in out [aInterface.name/] [for (par : Parameter | op.ownedParameter)];
[par.name/] : [if(par.direction.toString().equalsIgnoreCase('return'))]out[else][par.direction/][/if] [par.type.name/][/for]) is abstract;
[/if]
[/if]
[/for]
type [aInterface.name/]_ptr is access all [aInterface.name/]'class;
end [aInterface.name/];
[/file]
[/template]
[query public isDataTypeWithRequired(arg0 : Interface) : Boolean
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'isDataTypeWithRequired(org.eclipse.uml2.uml.Interface)', Sequence{arg0}) /]
[query public getDocumentation(arg : NamedElement) : String
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'getDocumentation(org.eclipse.uml2.uml.NamedElement)', Sequence{arg}) /]
[query public isFunction(arg : Operation) : Boolean
= invoke ('org.polarsys.chess.codegen.ada.service.UML2Service', 'isFunction(org.eclipse.uml2.uml.Operation)', Sequence{arg}) /]
[query public getReturnParam(arg : Operation) : Parameter
= invoke ('org.polarsys.chess.codegen.ada.service.UML2Service', 'getReturnParam(org.eclipse.uml2.uml.Operation)', Sequence{arg}) /]