Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ InfoChain infoChain(final String opName, final Nil<?> specialType,

InfoChain chainFromInfo(final OpInfo info, final Nil<?> specialType);

InfoChain chainFromInfo(final OpInfo info, final Nil<?> specialType, final Hints hints);

default OpBuilder op(final String opName) {
return new OpBuilder(this, opName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.scijava.ops.engine.impl;
package org.scijava.ops.api.features;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.scijava.ops.engine.matcher;
package org.scijava.ops.api.features;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -7,13 +7,12 @@
import org.scijava.ops.api.OpRef;
import org.scijava.ops.api.OpUtils;
import org.scijava.ops.api.OpCandidate.StatusCode;
import org.scijava.ops.api.features.OpMatchingException;

/**
* Class representing the result from type matching done by the
* {@link OpMatcher}. Contains the original candidates which match
* the types specified by {@link OpRef} and the final matches that match all
* inputs, outputs, and arguments.
* Class representing the result from type matching done by a
* {@link MatchingRoutine}. Contains the original candidates which match the
* types specified by {@link OpRef} and the final matches that match all inputs,
* outputs, and arguments.
*
* @author David Kolb
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

package org.scijava.ops.api.features;

import org.scijava.ops.api.OpCandidate;
import org.scijava.ops.api.OpEnvironment;
import org.scijava.plugin.Plugin;
import org.scijava.plugin.SciJavaPlugin;

/**
* A plugin type employing a particular strategy to generate an
* {@link OpCandidate}.
*
* @author Gabriel Selzer
*/
public interface MatchingRoutine extends SciJavaPlugin,
Comparable<MatchingRoutine>
{

void checkSuitability(MatchingConditions conditions)
throws OpMatchingException;

@Override
default int compareTo(MatchingRoutine o) {
return (int) (priority() - o.priority());
}

OpCandidate findMatch(MatchingConditions conditions, OpMatcher matcher,
OpEnvironment env) throws OpMatchingException;

/**
* Generates an {@link OpCandidate} from the Ops in the provided
* {@link OpEnvironment}, conforming to the provided
* {@link MatchingConditions}
*
* @param conditions the {@link MatchingConditions} the returned Op must
* conform to
* @param matcher the {@link OpMatcher} responsible for matching
* @param env the {@link OpEnvironment} containing the Ops able to be matched
* @return an {@OpCandidate}
*/
default OpCandidate match(MatchingConditions conditions, OpMatcher matcher,
OpEnvironment env)
{
checkSuitability(conditions);
return findMatch(conditions, matcher, env);
}

/**
* Since {@link MatchingRoutine}s should be {@link Plugin}s, we should be able
* to scrape the priority off of the plugin annotation.
*
* @return the priority
*/
default double priority() {
Plugin annotation = this.getClass().getAnnotation(Plugin.class);
if (annotation == null) return 0.;
return annotation.priority();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@
* #L%
*/

package org.scijava.ops.engine.matcher;
package org.scijava.ops.api.features;

import java.util.List;

import org.scijava.ops.api.Hints;
import org.scijava.ops.api.OpCandidate;
import org.scijava.ops.api.OpEnvironment;
import org.scijava.ops.api.OpRef;
import org.scijava.ops.engine.matcher.MatchingResult;

/**
* Finds Ops which match an {@link OpRef}.
Expand All @@ -45,27 +41,5 @@
//TODO javadoc
public interface OpMatcher {

OpCandidate findSingleMatch(OpEnvironment env, OpRef ref);

OpCandidate findSingleMatch(OpEnvironment env, OpRef ref, Hints hints);

MatchingResult findMatch(OpEnvironment env, OpRef ref);

MatchingResult findMatch(OpEnvironment env, OpRef ref, Hints hints);

MatchingResult findMatch(OpEnvironment env, List<OpRef> refs);

MatchingResult findMatch(OpEnvironment env, List<OpRef> refs, Hints hints);

List<OpCandidate> findCandidates(OpEnvironment env, OpRef ref);

List<OpCandidate> findCandidates(OpEnvironment env, OpRef ref, Hints hints);

List<OpCandidate> findCandidates(OpEnvironment env, List<OpRef> refs);

List<OpCandidate> findCandidates(OpEnvironment env, List<OpRef> refs, Hints hints);

List<OpCandidate> filterMatches(List<OpCandidate> candidates);

boolean typesMatch(OpCandidate candidate);
OpCandidate match(MatchingConditions conditions, OpEnvironment env);
}
3 changes: 2 additions & 1 deletion scijava/scijava-ops-engine/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
opens org.scijava.ops.engine.conversionLoss to therapi.runtime.javadoc;
opens org.scijava.ops.engine.copy to therapi.runtime.javadoc;
opens org.scijava.ops.engine.log to therapi.runtime.javadoc;
opens org.scijava.ops.engine.matcher to therapi.runtime.javadoc;
opens org.scijava.ops.engine.simplify to therapi.runtime.javadoc;
opens org.scijava.ops.engine.impl to therapi.runtime.javadoc, org.scijava;
opens org.scijava.ops.engine.conversionLoss.impl to therapi.runtime.javadoc, org.scijava;
Expand All @@ -31,6 +30,8 @@
opens org.scijava.ops.engine.util to therapi.runtime.javadoc;
opens org.scijava.ops.engine.math to therapi.runtime.javadoc;

requires java.desktop;

requires org.scijava;
requires org.scijava.discovery;
requires org.scijava.function;
Expand Down
Loading