From c04a4bd96accb96c4c9aca0558a4c2561f6d8a12 Mon Sep 17 00:00:00 2001 From: Ansgar Radermacher Date: Mon, 27 Jan 2014 17:17:48 +0100 Subject: - 424759 - [QDesginer] Need for more options when binding templates --- .../designer/core/extensions/BindingHelperExt.java | 4 +- .../core/extensions/IInstanceConfigurator.java | 2 +- .../core/extensions/InstanceConfigurator.java | 5 + .../designer/core/templates/BindingUtils.java | 9 +- .../templates/TemplateInstantiationListener.java | 154 +----- .../designer/core/templates/TemplateUtils.java | 68 +++ .../models/examples/ClientServerTimer.notation | 14 +- .../models/library/corba.uml | 2 +- .../models/library/core.notation | 94 +++- .../models/library/core.uml | 544 +++++++++++---------- .../models/library/statemachine.notation | 107 +++- .../models/library/statemachine.uml | 76 ++- .../core/bindinghelpers/BindOperation.java | 55 +++ .../core/bindinghelpers/LoopOperations.java | 45 +- 14 files changed, 697 insertions(+), 482 deletions(-) create mode 100644 extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/BindOperation.java (limited to 'extraplugins') diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/BindingHelperExt.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/BindingHelperExt.java index bbde28a4b23..c8e363d11a9 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/BindingHelperExt.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/BindingHelperExt.java @@ -20,6 +20,7 @@ import org.eclipse.papyrus.FCM.BindingHelper; import org.eclipse.papyrus.FCM.util.IBindingHelper; import org.eclipse.papyrus.qompass.designer.core.listeners.CopyListener; import org.eclipse.papyrus.qompass.designer.core.transformations.Copy; +import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationRTException; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.TemplateBinding; @@ -73,6 +74,7 @@ public class BindingHelperExt { exception.printStackTrace(); } } - return null; + throw new TransformationRTException( + String.format("Cannot find binding helper <%s>", helperName)); } } diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/IInstanceConfigurator.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/IInstanceConfigurator.java index 94df33a7003..3335a7b25cb 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/IInstanceConfigurator.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/IInstanceConfigurator.java @@ -32,5 +32,5 @@ public interface IInstanceConfigurator { * additional information, if the element that should be configured is part of a container, e.g. an interceptor * or an extension within the container. */ - public void configureInstance(InstanceSpecification instance, Property componentPart, InstanceSpecification parentInstnace); + public void configureInstance(InstanceSpecification instance, Property componentPart, InstanceSpecification parentInstance); } diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/InstanceConfigurator.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/InstanceConfigurator.java index acb0084e888..f932174ccc2 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/InstanceConfigurator.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/extensions/InstanceConfigurator.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.papyrus.FCM.ContainerRule; import org.eclipse.papyrus.FCM.UseInstanceConfigurator; import org.eclipse.papyrus.qompass.designer.core.Activator; +import org.eclipse.papyrus.qompass.designer.core.Messages; import org.eclipse.papyrus.qompass.designer.core.deployment.DepUtils; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.InstanceSpecification; @@ -100,6 +101,10 @@ public class InstanceConfigurator { for(IConfigurationElement configElement : configElements) { try { final String iConfiguratorIDext = configElement.getAttribute("configuratorID"); //$NON-NLS-1$ + if(iConfiguratorIDext == null) { + throw new RuntimeException(String.format( + Messages.InstanceConfigurator_InvalidPluginExtension, iConfiguratorID)); + } if(iConfiguratorIDext.equals(iConfiguratorID)) { // TODO: cache returned instance (avoid creating a new instance each time => more efficient, no need for static attributes) final Object obj = configElement.createExecutableExtension("class"); //$NON-NLS-1$ diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/BindingUtils.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/BindingUtils.java index 67aedf7fa24..27293a7923a 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/BindingUtils.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/BindingUtils.java @@ -37,7 +37,14 @@ import org.eclipse.uml2.uml.util.UMLUtil; public class BindingUtils { - public static Operation instantiateOperation(Copy copy, Element actual, Operation operation, Class boundClass) { + /** + * Bind an operation by copying the signature from the actual. + * @param copy the copier + * @param actual the actual. If an operation, its signature is copied to the template + * @param operation The operation template + * @return + */ + public static Operation instantiateOperation(Copy copy, Element actual, Operation operation) { try { Operation newOperation = copy.getCopy(operation); if(actual instanceof Operation) { diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/TemplateInstantiationListener.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/TemplateInstantiationListener.java index 2023871a381..9e3c5958ab4 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/TemplateInstantiationListener.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/TemplateInstantiationListener.java @@ -43,18 +43,11 @@ public class TemplateInstantiationListener implements CopyListener { } public void init(Copy copy, TemplateBinding binding, Object[] args) { - treatTemplate = false; - this.copy = copy; this.binding = binding; - this.args = args; } private TemplateBinding binding; - private Copy copy; - - private Object[] args; - private boolean treatTemplate; private static TemplateInstantiationListener templateInstantiationListener; @@ -70,138 +63,31 @@ public class TemplateInstantiationListener implements CopyListener { } protected EObject checkEObject(Copy copy, EObject sourceEObj) { - // try { - if(sourceEObj instanceof Element) { - if(sourceEObj instanceof OpaqueBehavior) { - OpaqueBehavior behavior = (OpaqueBehavior)sourceEObj; - // in case of a behavior, examine stereotype on associated operation - BehavioralFeature bf = behavior.getSpecification(); - if(bf != null) { - Template template = UMLUtil.getStereotypeApplication(bf, Template.class); - if(template != null) { - return null; - } + + // Specific treatment of OpaqueBehaviors: Template instantiations are typically managed + // by the associated operation which instantiates operation and behavior. In this case, the + // behavior should not be instantiated. + if(sourceEObj instanceof OpaqueBehavior) { + OpaqueBehavior behavior = (OpaqueBehavior)sourceEObj; + BehavioralFeature bf = behavior.getSpecification(); + if(bf != null) { + Template template = UMLUtil.getStereotypeApplication(bf, Template.class); + if(template != null) { + return null; } } - else { - Template template = UMLUtil.getStereotypeApplication((Element)sourceEObj, Template.class); - if((template != null)) { // && (!treatTemplateElement.containsKey(sourceEObj))) { - // treatTemplateElement.put(sourceEObj, true); - BindingHelper helper = template.getHelper(); - if (helper != null) { - return BindingHelperExt.applyHelper(helper, copy, binding, sourceEObj); - } - return sourceEObj; - - /* - if(sourceEObj instanceof Operation) { - Operation operation = (Operation)sourceEObj; - - Classifier actual = getFirstActualFromBinding(binding, operation); - Class boundClass = copy.getCopy(operation.getClass_()); - if(template.getKind() == TemplateKind.LOOP_OPERATIONS) { - // in case of loop operations, the template parameter is iteratively an - // operation of the actual (which should be an interface) in this case. - // - // The template operation typically inherits all parameters. This is expressed by - // a single parameter with the LOOP_PARAMETERS options (<%name%> as name, what as type?) - // cleaner (more general: if user writes loop with Acceleo as well?] - // // owns template operation parameter?? - Type passedActual = getPassedActual(template, actual, boundClass); - if(!(passedActual instanceof Interface)) { - return sourceEObj; - } - Interface passedActualIntf = (Interface)passedActual; - Operation last = null; - EList removalList = new BasicEList(); - for(Operation intfOperation : passedActualIntf.getAllOperations()) { - for(Element removalElement : removalList) { - copy.removeForCopy(removalElement); // enable subsequent instantiations - } - removalList.clear(); - last = instantiateOperation(intfOperation, template, operation, boundClass); - removalList.add(operation); - for(Behavior method : operation.getMethods()) { - if(method instanceof OpaqueBehavior) { - Behavior newBehavior = - instantiateBehavior(intfOperation, template, (OpaqueBehavior)method); - newBehavior.setSpecification(last); - // removalList.add(method); - copy.removeForCopy(method); // enable subsequent instantiations - } - } - } - // from a logical viewpoint, we need to copy parameters & name, but not the - // operation identity. - copy.put(operation, last); - return last; - } - else { - Operation newOperation = instantiateOperation(actual, template, operation, boundClass); - for(Behavior method : operation.getMethods()) { - if(method instanceof OpaqueBehavior) { - Behavior newBehavior = - instantiateBehavior(actual, template, (OpaqueBehavior)method); - newBehavior.setSpecification(newOperation); - } - } - return newOperation; - } - } - else if(sourceEObj instanceof EnumerationLiteral) { - if(template.getKind() == TemplateKind.LOOP_OPERATIONS) { - EnumerationLiteral literal = (EnumerationLiteral)sourceEObj; - Classifier actual = getFirstActualFromBinding(binding, literal); - // Type passedActual = getPassedActual(template, actual, boundClass); - Type passedActual = actual; - if(!(passedActual instanceof Interface)) { - return sourceEObj; - } - Interface passedActualIntf = (Interface)passedActual; - EnumerationLiteral newLiteral = null; - for(Operation intfOperation : passedActualIntf.getAllOperations()) { - copy.removeForCopy(literal); - newLiteral = copy.getCopy(literal); - String newName = AcceleoDriverWrapper.evaluate(literal.getName(), intfOperation, args); - newLiteral.setName(newName); - } - return newLiteral; - } - } - */ + } + + if(sourceEObj instanceof Element) { + + Template template = UMLUtil.getStereotypeApplication((Element)sourceEObj, Template.class); + if((template != null)) { + BindingHelper helper = template.getHelper(); + if (helper != null) { + return BindingHelperExt.applyHelper(helper, copy, binding, sourceEObj); } } } return sourceEObj; - - /* - } catch (TransformationException e) { - // throw runtime exception - throw new RuntimeException(String.format(Messages.TemplateInstantiationListener_TrafoException, e.getMessage())); - } - */ - } - - - /* - private Type getPassedActual(Template template, Type actual, Class boundClass) { - if(template.getActualChoice() == ActualChoice.INTERFACE_OF_PPORT) { - return getInterfaceFromPortTypedWithActual(actual, boundClass, true); - } else if(template.getActualChoice() == ActualChoice.INTERFACE_OF_RPORT) { - // TODO: typically does not make sense to loop over it. - return getInterfaceFromPortTypedWithActual(actual, boundClass, false); - } else if(template.getActualChoice() == ActualChoice.PASS_ACTUAL) { - return actual; - } else { - // default behavior (common use in connectors): in case of a loop over operations, return actual - // from provided port - // TODO: Again, this is a hack! - if(template.getKind() == TemplateKind.LOOP_OPERATIONS) { - return getInterfaceFromPortTypedWithActual(actual, boundClass, true); - } else { - return actual; - } - } } - */ } diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/TemplateUtils.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/TemplateUtils.java index 46e9e609071..6061217194d 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/TemplateUtils.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/templates/TemplateUtils.java @@ -19,18 +19,28 @@ import java.util.Iterator; import org.eclipse.core.runtime.Status; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; +import org.eclipse.papyrus.qompass.designer.core.ConnectorUtils; import org.eclipse.papyrus.qompass.designer.core.CreationUtils; import org.eclipse.papyrus.qompass.designer.core.Log; import org.eclipse.papyrus.qompass.designer.core.Messages; +import org.eclipse.papyrus.qompass.designer.core.PortUtils; +import org.eclipse.papyrus.qompass.designer.core.Utils; import org.eclipse.papyrus.qompass.designer.core.transformations.Copy; import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationException; import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.ConnectableElement; +import org.eclipse.uml2.uml.Connector; +import org.eclipse.uml2.uml.ConnectorEnd; import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.EncapsulatedClassifier; import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.Namespace; import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.PackageMerge; import org.eclipse.uml2.uml.ParameterableElement; +import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.StructuredClassifier; import org.eclipse.uml2.uml.TemplateBinding; import org.eclipse.uml2.uml.TemplateParameter; import org.eclipse.uml2.uml.TemplateParameterSubstitution; @@ -320,4 +330,62 @@ public class TemplateUtils { } return null; } + + /** + * Re-target connectors after a part has changed its type from template to an instantiation + * of this template. In this case, the roles of the connector ends still reference the port + * of the template instead of the bound template binding. + * The new roles are assigned based on an equal name, assuming that template instantiation + * does not change the name of the ports. + * + * @param composite a composite containing connectors + * @param part a part within the composite whose type has changed. + */ + public static void retargetConnectors(StructuredClassifier composite, Property part) { + Type partType = part.getType(); + if (partType instanceof EncapsulatedClassifier) { + EncapsulatedClassifier partTypeEC = (EncapsulatedClassifier) partType; + for(Connector connector : composite.getOwnedConnectors()) { + if(ConnectorUtils.connectsPart(connector, part)) { + // the connector end targets a port of a part or the composite (in case of delegation) + ConnectorEnd connEnd = ConnectorUtils.connEndForPart(connector, part); + // redirect role, if pointing to port + if(connEnd.getRole() instanceof Port) { + Port connectedTemplatePort = (Port)connEnd.getRole(); + Port connectedBoundPort = (Port)Utils.getNamedElementFromList( + PortUtils.getAllPorts(partTypeEC), connectedTemplatePort.getName()); + connEnd.setRole(connectedBoundPort); + } + } + } + } + } + + /** + * Re-target connectors after an unknown number of parts have changed their type from template + * to an instantiation of this template. In this case, the roles of the connector ends still + * reference the port of the template instead of the bound template binding. + * The new roles are assigned based on an equal name, assuming that template instantiation + * does not change the name of the ports. + * + * @param composite a composite containing connectors + */ + public static void retargetConnectors(StructuredClassifier composite) { + for(Connector connector : composite.getOwnedConnectors()) { + // the connector end targets a port of a part or the composite (in case of delegation) + for (ConnectorEnd connEnd : connector.getEnds()) { + Property part = connEnd.getPartWithPort(); + if ((part != null) && (part.getType() instanceof EncapsulatedClassifier)) { + EncapsulatedClassifier partTypeEC = (EncapsulatedClassifier) part.getType(); + ConnectableElement role = connEnd.getRole(); + EList ports = PortUtils.getAllPorts(partTypeEC); + if ((role instanceof Port) && !ports.contains(role)) { + // role is not in list of ports + Port connectedBoundPort = (Port)Utils.getNamedElementFromList(ports, role.getName()); + connEnd.setRole(connectedBoundPort); + } + } + } + } + } } diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/examples/ClientServerTimer.notation b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/examples/ClientServerTimer.notation index 10fdf737beb..02bc8ab2dfc 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/examples/ClientServerTimer.notation +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/examples/ClientServerTimer.notation @@ -331,6 +331,9 @@
+ +
+ @@ -368,7 +371,7 @@ - + @@ -426,7 +429,7 @@ - + @@ -474,7 +477,7 @@ - + @@ -581,7 +584,7 @@ - + @@ -776,6 +779,9 @@
+ +
+ diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/corba.uml b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/corba.uml index 5b3a32464ac..bf073e2fe0b 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/corba.uml +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/corba.uml @@ -48,7 +48,7 @@ - + diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/core.notation b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/core.notation index 17f6b6cd0f8..535d9d22a88 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/core.notation +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/core.notation @@ -1971,6 +1971,43 @@ + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + @@ -2026,6 +2063,13 @@ + + + + + + + @@ -4339,7 +4383,7 @@ - +
@@ -4356,20 +4400,23 @@
+ +
+ - + - + - + @@ -4382,6 +4429,45 @@ + + +
+
+
+
+
+ + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/core.uml b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/core.uml index b05f017b9bd..84419428706 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/core.uml +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/core.uml @@ -1,24 +1,24 @@ - + - + - + - + - + - + currently unused, not sure whether really needed @@ -51,14 +51,14 @@ m_[part.name/] = [part.name/] [/for] [/template] - - + + - + A template for the bootloader generation. - + This C++ implementation of the template contains principally the definition of the "main" function and the declaration of the bootloader instance @@ -67,50 +67,50 @@ m_[part.name/] = [part.name/] <%createInstances%> - - + + - + Main package template for all call based connectors. The formal parameter is the interface I (which is bound to the actual interface used in a call). This package is virtually extended by other model libraries who import it. - + Inheritance hierarchy for (A)SyncCall component types. Separate types for required (rconn) and provided (fconn) ports enable re-use via inheritance ain multiple places (e.g. for AMI ports that use an unmodified provided port and different variants of a required port). Note that ports on connector side are conjugated - + - - + + - + Description: A simple implementation of asynchronous calls. It will execution requests by means of a single dispatcher thread - + Simple asynchronous call implementation: returns immediately and executes request in new thread - + Uses buffer and ASN marshalling. TODO: configurable buffer size, use data structure (CppParameterStorage) - - + + - + - + C/C++ [import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/] @@ -171,8 +171,8 @@ switch (operationID) } [/template] - - + + @@ -180,28 +180,28 @@ switch (operationID) - + - - + + - + (untested) implementation of an asynchronous invocation that uses a thread pool for spawning new requests - - + + - + - + C/C++ [template marshall(operation: Operation)] @@ -270,8 +270,8 @@ switch (operationID) [/template] - - + + @@ -279,34 +279,34 @@ switch (operationID) - + - - + + - + Description: A simple implementation of asynchronous calls. It will execution requests by means of a single dispatcher thread - + Polling variant of corbas asynchronous messaging (AMI), enables asynchronous calls while reading return values (also called deferred synchronous): Instead of specified return values, functions return a poller object which may be queried for the result. TODO: complete, move into model of Qompass AMI plugin - - + + - + - + C/C++ [import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/] @@ -396,8 +396,8 @@ switch (operationID) [/template] - - + + @@ -405,16 +405,16 @@ switch (operationID) - + - - + + - - + + C/C++ [import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/] @@ -428,15 +428,15 @@ for (int i=0; i<9; i++) { } [/template] - + - - + + - + @@ -451,13 +451,13 @@ for (int i=0; i<9; i++) { - + Needs completion: good(?) write buffer event? Call operations of buffer component? [could have done in an identical way for EventPool] - + Marshalling is done at two levels: (1) In case of a shared address space, only a callEvent is created. It can be passed between threads within a process. (2) For remote communication, marshalling into a buffer is done. @@ -494,7 +494,7 @@ Call operations of buffer component? - + C/C++ [template marshallStruct(operation : Operation)] @@ -512,10 +512,10 @@ ParamData * data = &event.params; [/for] out->dispatch(event); - + - + @@ -525,14 +525,14 @@ out->dispatch(event); - + - + @@ -541,21 +541,21 @@ out->dispatch(event); - - + + - + Description: This connector is a kind of dummy connector, since it only passes incoming requests to its caller port - + Minimal connector implementation that does nothing (but passing requests) - + - - + + C/C++ [import org::eclipse::papyrus::qompass::designer::core::acceleo::utils_cpp/] @@ -567,48 +567,48 @@ out->dispatch(event); // put post-interceptors here [/template] - + - - + + C/C++ cout << "this is a sample pre-call interception" << endl; rconn-><%cppCall%>; cout << "this is a sample post-call interception" << endl; - + - + A set of Leader followers is instantiated. Each has its own thread and a semaphore. The LF instance waits on its semaphore. When selectLeader is called, a follower is signaled (semaphore is posted) and will become leader. The leader waits for a resource (e.g. a socket) and becomes executor. - + - + - - - + + + - - + + - + C/C++ for (;;) { @@ -653,45 +653,45 @@ m_state = FOLLOWER; C/C++ ((LeaderFollower *) arg)->run(); - - - - - - + + + + + + - + - - + + - - + + - - + + - - - + + + - - + + - - - + + + @@ -706,137 +706,141 @@ m_state = FOLLOWER; - + Simple provision of typing interface as provided interface - + Simple provision of typing interface as required interface - + corba asynchronous messaging (AMI): Provision of poller variant of typing interface. Allows client to continue without waiting for the result - + corba asynchronous messaging (AMI): Provision of callback variant of typing interface. Allows client Allows client to continue without waiting for the result - + Data Flow oriented communication: consume passively: provided push operation is called - + Data Flow oriented communication: produce data via pushing these (calling the required operation) - + Data Flow oriented communication: produce data via pushing these (calling the required operation) - + Data Flow oriented communication: produce data via pushing these (calling the required operation) - + Data Flow oriented communication: consumer data actively by calling the required poll operation - + In order to support icons, all port kinds are stereotypes, but for Qompass they are classes stereotyped as "PortKind" - + A bidirectional flow port combining a push-producer and a pull consumer + + Dummy interface returned by ports who need to update derived interfaces (but can only do so in the context of a transaction). + - - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - -
-
+ + +
+
- - + + - - + + + - + Is called during component activation & deactivation. The two functions may not block i.e. return control to the caller after "a very short" period - + Is called during startup. Expected to block. Only one component instance per node may define it. @@ -848,22 +852,22 @@ m_state = FOLLOWER; - + A thread service supporting the LifeCycle port. Once started, it calls the activate operation (via the required port rLC) of a connected component in a new thread of a specific priority (a configuration attribute). This C++ implementation is based on the POSIX pthread library. It will further assume that the execution is done with root privileges, since these are required to set the thread priority. The thread properties assume round-robin (SCHED_RR) scheduling. - + Interceptor variant of thread (inherits all, only difference to Thread superclass: tagged as connector) - + Priority of the thread. The interpretation of the value is OS specific. In case of POSIX; priorities are only taken into accound for threads with a FIFO and round-robin scheduliung policy. - + - + @@ -871,17 +875,17 @@ m_state = FOLLOWER; - + - + - + - + @@ -904,23 +908,23 @@ pthread_setschedparam (pt, SCHED_RR, &schedParam); // TODO: check return code (in particular, SCHED_RR only works for root) - - + + - + - - - + + + - + @@ -928,19 +932,19 @@ pthread_setschedparam (pt, SCHED_RR, &schedParam); - + - + - + @@ -956,14 +960,14 @@ pthread_setschedparam (pt, SCHED_RR, &schedParam); - + - + @@ -971,7 +975,7 @@ pthread_setschedparam (pt, SCHED_RR, &schedParam); - + @@ -979,13 +983,13 @@ pthread_setschedparam (pt, SCHED_RR, &schedParam); - + - + C/C++ events[0] = event; @@ -1014,56 +1018,56 @@ return events[0]; C/C++ m_cond.lock(); - - + + - + - - + + - - + + - + - - + + <<TextualRepresentation>>public abstract writeEvent (in event:BasicCalls::ContainerServices::Event) ; - + - - - + + + - - - - + + + + <<TextualRepresentation>>public abstract size () : BasicCalls::Long ; - + @@ -1071,29 +1075,29 @@ return events[0]; - - + + <<TextualRepresentation>>public abstract readEvent(in timeout : BasicCalls::Long) : BasicCalls::ContainerServices::Event ; - + - + - + - + The period length of the perdioci timer in ticks. Currently, a tick corresponds to 1 ms (simulation time in the underlying OS abstraction layer). It is planned to support VSL expressions, i.e. a value/unit pair. - + @@ -1102,7 +1106,7 @@ return events[0]; - + @@ -1110,9 +1114,9 @@ return events[0]; - + - + C/C++ @@ -1125,12 +1129,12 @@ for (;;) { timer.wakeUp(time); } - - - + + + - + @@ -1139,14 +1143,14 @@ for (;;) { - + - + @@ -1161,22 +1165,22 @@ for (;;) { - - + + - + - - + + - + @@ -1186,7 +1190,7 @@ for (;;) { - + @@ -1196,7 +1200,7 @@ for (;;) { - + @@ -1204,7 +1208,7 @@ for (;;) { - + @@ -1212,7 +1216,7 @@ for (;;) { - + @@ -1230,14 +1234,14 @@ for (;;) { - + This rule adds an interceptor for the lifecycle (lc) port. It will use the Thread implementation that executes the activate method in a new thread of a given priority (property of the interceptor implementation) - + Adds a periodic timer to the container - + @@ -1260,17 +1264,17 @@ for (;;) { - + Use for distributed applications - + Use for debugging in general - + Use for tracing. @@ -1279,35 +1283,35 @@ for (;;) { - + - + - + Elements in this package depend not only on the Interface I (which is a non-owned template parameter taken from the methodCall signature), but also on a class parameter T, which is bound to the component within a container binding. Be aware that the number of instantiated template packages will be considerably larger compared to a dependency of the interface only - + - - + + - + @@ -1320,30 +1324,31 @@ Be aware that the number of instantiated template packages will be considerably + - - + + - + - - + + - + - - + + - + - - + + - + @@ -1410,8 +1415,8 @@ Be aware that the number of instantiated template packages will be considerably - - + + @@ -1474,8 +1479,8 @@ Be aware that the number of instantiated template packages will be considerably - - + + @@ -1484,7 +1489,7 @@ Be aware that the number of instantiated template packages will be considerably - + @@ -1519,7 +1524,7 @@ Be aware that the number of instantiated template packages will be considerably - + @@ -1542,4 +1547,5 @@ Be aware that the number of instantiated template packages will be considerably + diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/statemachine.notation b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/statemachine.notation index 14fb5b3fd8d..3083be6a696 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/statemachine.notation +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/statemachine.notation @@ -53,7 +53,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -205,7 +205,7 @@ - + @@ -234,7 +234,7 @@ - + @@ -669,7 +669,7 @@ - + @@ -784,7 +784,7 @@ - + @@ -813,7 +813,7 @@ - + @@ -868,7 +868,7 @@ - + @@ -897,7 +897,7 @@ - + @@ -1481,13 +1481,20 @@
+ +
+
+
+
+
+
- + @@ -1534,7 +1541,17 @@
+ +
+
+
+
+
+ + +
+ @@ -1548,7 +1565,7 @@ - + @@ -1579,13 +1596,20 @@
+ +
+
+
+
+
+
- + @@ -1601,13 +1625,20 @@
+ +
+
+
+
+
+
- + @@ -1623,13 +1654,20 @@
+ +
+
+
+
+
+
- + @@ -1640,7 +1678,7 @@ - + @@ -1671,13 +1709,20 @@
+ +
+
+
+
+
+
- + @@ -1719,13 +1764,20 @@
+ +
+
+
+
+
+
- + @@ -1787,8 +1839,9 @@ - + + @@ -1805,16 +1858,16 @@ - + -
-
-
-
-
+
+
+
+
+
@@ -1830,7 +1883,7 @@ - + diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/statemachine.uml b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/statemachine.uml index 14b0ff02a5b..513b181584f 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/statemachine.uml +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/models/library/statemachine.uml @@ -125,6 +125,7 @@ out->writeEvent (event); + @@ -158,7 +159,21 @@ out->writeEvent (event); - + + C/C++ + if (outAnimSvc != 0) { + outAnimSvc->leaveState(stateEnum, eInstance); +} + + + + C/C++ + if (outAnimSvc != 0) { + outAnimSvc->enterState(stateEnum, eInstance); +} + + + @@ -170,8 +185,8 @@ out->writeEvent (event); - - + + @@ -216,20 +231,45 @@ out->writeEvent (event); - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -237,14 +277,14 @@ out->writeEvent (event); - + - + @@ -289,14 +329,14 @@ out->writeEvent (event); - + - + @@ -304,14 +344,14 @@ out->writeEvent (event); - + - + @@ -409,7 +449,9 @@ out->writeEvent (event); - + + + @@ -418,9 +460,6 @@ out->writeEvent (event); - - - @@ -434,4 +473,9 @@ out->writeEvent (event); + + + + + diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/BindOperation.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/BindOperation.java new file mode 100644 index 00000000000..61fb5030c0c --- /dev/null +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/BindOperation.java @@ -0,0 +1,55 @@ +package org.eclipse.papyrus.qompass.modellibs.core.bindinghelpers; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.FCM.util.IBindingHelper; +import org.eclipse.papyrus.qompass.designer.core.listeners.CopyListener; +import org.eclipse.papyrus.qompass.designer.core.templates.BindingUtils; +import org.eclipse.papyrus.qompass.designer.core.templates.TemplateUtils; +import org.eclipse.papyrus.qompass.designer.core.transformations.Copy; +import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationException; +import org.eclipse.papyrus.qompass.modellibs.core.Activator; +import org.eclipse.uml2.uml.Behavior; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.OpaqueBehavior; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.TemplateBinding; + +/** + * Bind an operation to an actual, i.e. evaluate the Acceleo template within the opaque behavior associated with + * the operation. + */ +public class BindOperation implements IBindingHelper, CopyListener { + + private TemplateBinding binding; + + @Override + public EObject copyEObject(Copy copy, EObject sourceEObj) { + + if(sourceEObj instanceof Operation) { + Operation operation = (Operation) sourceEObj; + Classifier actual = TemplateUtils.getFirstActualFromBinding(binding); + + Operation newOperation = BindingUtils.instantiateOperation(copy, actual, operation); + for(Behavior method : operation.getMethods()) { + if(method instanceof OpaqueBehavior) { + try { + Behavior newBehavior = + BindingUtils.instantiateBehavior(copy, actual, (OpaqueBehavior)method); + newBehavior.setSpecification(newOperation); + } + catch (TransformationException e) { + Activator.log.error(e); + } + } + } + return newOperation; + } + return sourceEObj; + } + + @Override + public void handleElement(TemplateBinding binding, Element object) { + this.binding = binding; + } +} diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java index 2f9874c8b1e..11f066f202b 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java @@ -12,7 +12,6 @@ import org.eclipse.papyrus.qompass.designer.core.transformations.Copy; import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationException; import org.eclipse.papyrus.qompass.modellibs.core.Activator; import org.eclipse.uml2.uml.Behavior; -import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.EnumerationLiteral; @@ -26,14 +25,12 @@ public class LoopOperations implements IBindingHelper, CopyListener { private TemplateBinding binding; - @Override public EObject copyEObject(Copy copy, EObject sourceEObj) { if(sourceEObj instanceof Operation) { Operation operation = (Operation)sourceEObj; Classifier actual = TemplateUtils.getFirstActualFromBinding(binding); - Class boundClass = copy.getCopy(operation.getClass_()); if(!(actual instanceof Interface)) { return sourceEObj; @@ -46,7 +43,7 @@ public class LoopOperations implements IBindingHelper, CopyListener { copy.removeForCopy(removalElement); // enable subsequent instantiations } removalList.clear(); - last = BindingUtils.instantiateOperation(copy, intfOperation, operation, boundClass); + last = BindingUtils.instantiateOperation(copy, intfOperation, operation); removalList.add(operation); for(Behavior method : operation.getMethods()) { if(method instanceof OpaqueBehavior) { @@ -81,29 +78,29 @@ public class LoopOperations implements IBindingHelper, CopyListener { */ } else if(sourceEObj instanceof EnumerationLiteral) { - EnumerationLiteral literal = (EnumerationLiteral)sourceEObj; - Classifier actual = TemplateUtils.getFirstActualFromBinding(binding); - // Type passedActual = getPassedActual(template, actual, boundClass); - Type passedActual = actual; - if(!(passedActual instanceof Interface)) { - return sourceEObj; + EnumerationLiteral literal = (EnumerationLiteral)sourceEObj; + Classifier actual = TemplateUtils.getFirstActualFromBinding(binding); + // Type passedActual = getPassedActual(template, actual, boundClass); + Type passedActual = actual; + if(!(passedActual instanceof Interface)) { + return sourceEObj; + } + Interface passedActualIntf = (Interface)passedActual; + EnumerationLiteral newLiteral = null; + for(Operation intfOperation : passedActualIntf.getAllOperations()) { + copy.removeForCopy(literal); + newLiteral = copy.getCopy(literal); + try { + String newName = AcceleoDriverWrapper.evaluate(literal.getName(), intfOperation, null); + newLiteral.setName(newName); } - Interface passedActualIntf = (Interface)passedActual; - EnumerationLiteral newLiteral = null; - for(Operation intfOperation : passedActualIntf.getAllOperations()) { - copy.removeForCopy(literal); - newLiteral = copy.getCopy(literal); - try { - String newName = AcceleoDriverWrapper.evaluate(literal.getName(), intfOperation, null); - newLiteral.setName(newName); - } - catch (TransformationException e) { - Activator.log.error(e); - newLiteral.setName("none"); //$NON-NLS-1$ - } + catch (TransformationException e) { + Activator.log.error(e); + newLiteral.setName("none"); //$NON-NLS-1$ } - return newLiteral; } + return newLiteral; + } return null; } -- cgit v1.2.1