diff options
Diffstat (limited to 'subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/ILocalSearchAdapter.java')
-rw-r--r-- | subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/ILocalSearchAdapter.java | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/ILocalSearchAdapter.java b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/ILocalSearchAdapter.java new file mode 100644 index 00000000..df64b5f1 --- /dev/null +++ b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/ILocalSearchAdapter.java | |||
@@ -0,0 +1,120 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2014, Marton Bur, Akos Horvath, Zoltan Ujhelyi, Istvan Rath and Daniel Varro | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package tools.refinery.viatra.runtime.localsearch.matcher; | ||
10 | |||
11 | import java.util.Optional; | ||
12 | |||
13 | import tools.refinery.viatra.runtime.localsearch.ExecutionLoggerAdapter; | ||
14 | import tools.refinery.viatra.runtime.localsearch.MatchingFrame; | ||
15 | import tools.refinery.viatra.runtime.localsearch.operations.ISearchOperation; | ||
16 | import tools.refinery.viatra.runtime.localsearch.plan.SearchPlan; | ||
17 | import tools.refinery.viatra.runtime.localsearch.profiler.LocalSearchProfilerAdapter; | ||
18 | |||
19 | |||
20 | /** | ||
21 | * A local search adapter allows external code to follow the internal executions of the local search matcher. Possible | ||
22 | * implementations of the interface include profilers and debuggers. | ||
23 | * <p> | ||
24 | * <strong>EXPERIMENTAL</strong>. A few shortcomings have been found for this interface late during the development | ||
25 | * lifecycle of version 2.0 whose solution might need breaking possible future implementors. Because of this, right now | ||
26 | * it is not recommended to provide implementations outside of VIATRA. If necessary, have a look at the built-in | ||
27 | * adapters that should fulfill most cases in the meantime. See bugs https://bugs.eclipse.org/bugs/show_bug.cgi?id=535101 | ||
28 | * and https://bugs.eclipse.org/bugs/show_bug.cgi?id=535102 for details. | ||
29 | * | ||
30 | * @author Marton Bur | ||
31 | * @see ExecutionLoggerAdapter | ||
32 | * @see LocalSearchProfilerAdapter | ||
33 | * | ||
34 | */ | ||
35 | public interface ILocalSearchAdapter { | ||
36 | |||
37 | /** | ||
38 | * | ||
39 | * @since 1.2 | ||
40 | */ | ||
41 | default void adapterRegistered(ILocalSearchAdaptable adaptable) {}; | ||
42 | /** | ||
43 | * | ||
44 | * @since 1.2 | ||
45 | */ | ||
46 | default void adapterUnregistered(ILocalSearchAdaptable adaptable) {}; | ||
47 | |||
48 | /** | ||
49 | * Callback method to indicate the start of a matching process | ||
50 | * | ||
51 | * @param lsMatcher the local search matcher that starts the matching | ||
52 | */ | ||
53 | default void patternMatchingStarted(LocalSearchMatcher lsMatcher) {}; | ||
54 | |||
55 | /** | ||
56 | * Callback method to indicate the end of a matching process | ||
57 | * </p> | ||
58 | * <strong>WARNING</strong>: It is not guaranteed that this method will be called; | ||
59 | * it is possible that a match process will end after a match is found and no other matches are accessed. | ||
60 | * | ||
61 | * @param lsMatcher the local search matcher that finished | ||
62 | * @since 2.0 | ||
63 | */ | ||
64 | default void noMoreMatchesAvailable(LocalSearchMatcher lsMatcher) {}; | ||
65 | |||
66 | /** | ||
67 | * Callback method to indicate switching to a new plan during the execution of a pattern matching | ||
68 | * | ||
69 | * @param oldPlan the plan that is finished. Value is null when the first plan is starting. | ||
70 | * @param newPlan the plan that will begin execution | ||
71 | * @since 2.0 | ||
72 | */ | ||
73 | default void planChanged(Optional<SearchPlan> oldPlan, Optional<SearchPlan> newPlan) {}; | ||
74 | |||
75 | /** | ||
76 | * Callback method to indicate the selection of an operation to execute | ||
77 | * | ||
78 | * @param plan the current plan executor | ||
79 | * @param frame the current matching frame | ||
80 | * @param isBacktrack if true, the selected operation was reached via backtracking | ||
81 | * @since 2.0 | ||
82 | */ | ||
83 | default void operationSelected(SearchPlan plan, ISearchOperation operation, MatchingFrame frame, boolean isBacktrack) {}; | ||
84 | |||
85 | /** | ||
86 | * Callback method to indicate that an operation is executed | ||
87 | * | ||
88 | * @param plan the current plan | ||
89 | * @param frame the current matching frame | ||
90 | * @param isSuccessful if true, the operation executed successfully, or false if the execution failed and backtracking will happen | ||
91 | * @since 2.0 | ||
92 | */ | ||
93 | default void operationExecuted(SearchPlan plan, ISearchOperation operation, MatchingFrame frame, boolean isSuccessful) {}; | ||
94 | |||
95 | /** | ||
96 | * Callback that is used to indicate that a match has been found | ||
97 | * | ||
98 | * @param plan the search plan executor that found the match | ||
99 | * @param frame the frame that holds the substitutions of the variables that match | ||
100 | * @since 2.0 | ||
101 | */ | ||
102 | default void matchFound(SearchPlan plan, MatchingFrame frame) {}; | ||
103 | /** | ||
104 | * Callback that is used to indicate that the previously reported match has been found as a duplicate, thus will be ignored from the match results. | ||
105 | * | ||
106 | * @param plan the search plan executor that found the match | ||
107 | * @param frame the frame that holds the substitutions of the variables that match | ||
108 | * @since 2.0 | ||
109 | */ | ||
110 | default void duplicateMatchFound(MatchingFrame frame) {}; | ||
111 | |||
112 | /** | ||
113 | * Callback method to indicate that a search plan is initialized in an executor with the given frame and starting operation | ||
114 | * | ||
115 | * @param searchPlan | ||
116 | * @param frame | ||
117 | * @since 2.0 | ||
118 | */ | ||
119 | default void executorInitializing(SearchPlan searchPlan, MatchingFrame frame) {}; | ||
120 | } | ||