| /******************************************************************************* |
| * Copyright (c) 2004-2008 Akos Horvath, Gergely Varro and Daniel Varro |
| * 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-v10.html |
| * |
| * Contributors: |
| * Akos Horvath, Gergely Varro - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.algorithms;
|
|
|
| import org.eclipse.viatra2.core.IModelManager;
|
| import org.eclipse.viatra2.gtasm.patternmatcher.PatternCallSignature; |
| import org.eclipse.viatra2.gtasm.patternmatcher.exceptions.PatternMatcherCompileTimeException; |
| import org.eclipse.viatra2.gtasm.patternmatcher.exceptions.PatternMatcherRuntimeException; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.gtmatcher.exceptions.GTRuleBuildingException; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.gtmatcher.internal.GTElementMapping; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.gtmatcher.internal.GTOperationContext; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.callgraph.BodyNode; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.callgraph.FlattenedPattern; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.callgraph.PatternReferenceNode; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.operation.SearchPlanOperation; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.searchgraph.AbstractNode; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.searchgraph.SearchGraphEdge; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.searchgraph.SearchGraphNode; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.searchgraph.traceability.EdgeTraceabilityElement; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.searchgraph.traceability.NodeTraceabilityElement; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.core.AnnotatedElement; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.core.GTASMElement; |
|
|
| import java.util.Collection;
|
| import java.util.TreeMap;
|
|
|
|
|
| /**Interface for the search graph used in the optimization algorithm |
| * @author Akos Horvath |
| * |
| */ |
| public interface ISearchGraph {
|
|
|
|
|
| public static final String VPM_RELATION_FQN = "vpm.relation";
|
| public static final String VPM_ENTITY_FQN = "vpm.entity";
|
| public static final int VARIABLEASSIGNMENT_WEIGHT = 5;
|
|
|
|
|
| //These are the methods that are used by the optimization algorithms
|
| public TreeMap<Integer, SearchGraphNode> getSearchNodes();
|
| /** Returns the search operation generated from the search graph parametrized with the input parameters adornment
|
| * @param pattern The flattened pattern to generate from
|
| * @param adornment Adornment of the input parameter
|
| * @param manager
|
| * @return Vector of the Operation plan
|
| * @throws PatternMatcherRuntimeException
|
| */
|
| public Collection<SearchPlanOperation> generateSearchPlan(FlattenedPattern pattern, Boolean[] adornment, IModelManager manager) throws PatternMatcherRuntimeException;
|
| /**
|
| * Initializes the search graph
|
| */
|
| public void initSearchGraph();
|
| public void add(BodyNode node, FlattenedPattern result) throws PatternMatcherCompileTimeException;
|
| /** Adds a pattern invocation node to the search graph
|
| * @param prNode The new pattern invocation node
|
| * @param result The flattened pattern of the search graph
|
| * @throws PatternMatcherCompileTimeException
|
| */
|
| public void add(PatternReferenceNode prNode, FlattenedPattern result) throws PatternMatcherCompileTimeException;
|
| /** Returns the generated GTOperations and variable mapping
|
| * @param gtElementMappings The RHS-LHS parameter mapping
|
| * @param manager Model manager of the actual framework
|
| * @param signature The input parameters' signatures
|
| * @return
|
| * @throws GTRuleBuildingException
|
| */
|
| public GTOperationContext generateGTOperations(Collection<GTElementMapping> gtElementMappings, IModelManager manager, PatternCallSignature[] signature) throws GTRuleBuildingException;
|
| /** Returns the search graph element with the input id |
| * @param key The id of the search graph element |
| * @return |
| */ |
| public SearchGraphNode getSearchNode(Integer key);
|
| /** Evaluates the dangling relations and relationships and adds them to the flattened pattern's search graph
|
| * @param pattern Flattened Pattern of the search graph
|
| * @throws PatternMatcherCompileTimeException
|
| */
|
| public void connectDanglingRelations(FlattenedPattern pattern) throws PatternMatcherCompileTimeException; |
| /**Return the EMF equivalent of the input SearchGraph element |
| * @param node The node whose EMF representation is returned |
| * @return |
| */ |
| public AnnotatedElement getGTASMRepresentation(AbstractNode node); |
| |
| /**To add an edge based traceability element to the search graph |
| * @param edge The edge whose element is added |
| * @param element The traceability element |
| */ |
| public void addTraceabilityElement(SearchGraphEdge edge, EdgeTraceabilityElement element); |
| |
| /**To add a node based traceability element to the search graph |
| * @param edge The edge whose element is added |
| * @param element The traceability element |
| */ |
| public void addTraceabilityElement(SearchGraphNode node, NodeTraceabilityElement element); |
|
|
| }
|