- java.lang.Object
-
- org.scijava.ops.engine.matcher.convert.ConvertedOpInfo
-
- All Implemented Interfaces:
Comparable<OpInfo>,OpInfo
public class ConvertedOpInfo extends Object implements OpInfo
AnOpInfowhose input and output types are transformed through the use ofengine.convertFunctionOps. Op instances created by thisOpInfoutilize aengine.convert"preconverter" Op to coerce each provided input to the type expected by the Op, and after execution use aengine.convert"postconverter" Op to coerce the output back into the type expected by the user. If the Op defines a preallocated output buffer, aengine.copyComputers.Arity1Op is used to place the computational results of the Op back into the passed output buffer.As an example, consider a
Function<Double, Double>. If we have aengine.convertOp that goes fromIntegertoDoubleand aengine.convertOp that goes fromDoubletoIntegerthen we can construct aFunction<Integer, Integer>Op. At runtime, we will utilize the formerengine.convertOp to preconvert the inputIntegerinto aDouble, invoke theFunction<Double, Double>, and then postconvert theDoubleinto anIntegerusing the latterengine.convertOp, which is returned to the user.- Author:
- Gabriel Selzer
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringIMPL_DECLARATIONIdentifiers for declaring a conversion in an Op signatureprotected static StringORIGINAL_INFOprotected static StringOUTPUT_COPIER_DELIMITERprotected static StringPOSTCONVERTER_DELIMITERprotected static StringPRECONVERTER_DELIMITER
-
Constructor Summary
Constructors Constructor Description ConvertedOpInfo(OpInfo info, Type opType, List<RichOp<Function<?,?>>> preconverters, List<Type> reqInputs, RichOp<Function<?,?>> postconverter, Type reqOutput, RichOp<Computers.Arity1<?,?>> copyOp, OpEnvironment env, Map<TypeVariable<?>,Type> typeVarAssigns)ConvertedOpInfo(OpInfo info, List<RichOp<Function<?,?>>> preconverters, RichOp<Function<?,?>> postconverter, RichOp<Computers.Arity1<?,?>> copyOp, OpEnvironment env)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(OpInfo that)StructInstance<?>createOpInstance(List<?> dependencies)Creates a converted version of the original Op, whose parameter types are dictated by the input types of this info's preconverters.HintsdeclaredHints()Stringdescription()AnnotatedElementgetAnnotationBearer()Stringid()For a converted Op, we define the implementation as the concatenation of: The signature of all preconverters The signature of the postconverter The signature of the output copier The id of the source OpStringimplementationName()List<String>names()TypeopType()doublepriority()OpInfosrcInfo()Structstruct()StringtoString()Map<TypeVariable<?>,Type>typeVarAssigns()Stringversion()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.scijava.ops.api.OpInfo
inputs, inputTypes, output, outputs, outputType
-
-
-
-
Field Detail
-
IMPL_DECLARATION
protected static final String IMPL_DECLARATION
Identifiers for declaring a conversion in an Op signature- See Also:
- Constant Field Values
-
PRECONVERTER_DELIMITER
protected static final String PRECONVERTER_DELIMITER
- See Also:
- Constant Field Values
-
POSTCONVERTER_DELIMITER
protected static final String POSTCONVERTER_DELIMITER
- See Also:
- Constant Field Values
-
OUTPUT_COPIER_DELIMITER
protected static final String OUTPUT_COPIER_DELIMITER
- See Also:
- Constant Field Values
-
ORIGINAL_INFO
protected static final String ORIGINAL_INFO
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConvertedOpInfo
public ConvertedOpInfo(OpInfo info, List<RichOp<Function<?,?>>> preconverters, RichOp<Function<?,?>> postconverter, RichOp<Computers.Arity1<?,?>> copyOp, OpEnvironment env)
-
-
Method Detail
-
srcInfo
public OpInfo srcInfo()
-
description
public String description()
- Specified by:
descriptionin interfaceOpInfo
-
declaredHints
public Hints declaredHints()
- Specified by:
declaredHintsin interfaceOpInfo
-
implementationName
public String implementationName()
- Specified by:
implementationNamein interfaceOpInfo
-
getAnnotationBearer
public AnnotatedElement getAnnotationBearer()
- Specified by:
getAnnotationBearerin interfaceOpInfo
-
createOpInstance
public StructInstance<?> createOpInstance(List<?> dependencies)
Creates a converted version of the original Op, whose parameter types are dictated by the input types of this info's preconverters. The resulting Op uses those preconverters to convert the inputs. After invoking the original Op, this Op will use this info's postconverters to convert the output into the type requested by the user. If the request defines a preallocated output buffer, this Op will also take care to copy the postconverted output back into the user-provided output buffer.- Specified by:
createOpInstancein interfaceOpInfo- Parameters:
dependencies- - this Op's dependencies
-
compareTo
public int compareTo(OpInfo that)
- Specified by:
compareToin interfaceComparable<OpInfo>- Specified by:
compareToin interfaceOpInfo
-
id
public String id()
For a converted Op, we define the implementation as the concatenation of:- The signature of all preconverters
- The signature of the postconverter
- The signature of the output copier
- The id of the source Op
-
typeVarAssigns
public Map<TypeVariable<?>,Type> typeVarAssigns()
-
-