Package io.engineblock.activityapi.core
Interface ActivityType<A extends Activity>
-
- All Superinterfaces:
Named
public interface ActivityType<A extends Activity> extends Named
An ActivityType is the central extension point in EngineBlock for new activity types drivers. It is responsible for naming the activity type, as well as providing the input, activity, and motor instances that will be assembled into an activity.
At the very minimum, a useful implementation of an activity type should provide an action dispenser. Default implementations of input and motor dispensers are provided, and by extension, default inputs and motors.
-
-
Field Summary
Fields Modifier and Type Field Description static SimpleServiceLoader<ActivityType>FINDER
-
Method Summary
Modifier and Type Method Description default ActionDispensergetActionDispenser(A activity)This method will be called once per action instance.default AgetActivity(ActivityDef activityDef)Create an instance of an activity from the activity type.default ActivitygetAssembledActivity(ActivityDef activityDef, java.util.Map<java.lang.String,Activity> activities)Create an instance of an activity that ties together all the components into a usable activity instance.default InputDispensergetInputDispenser(A activity)Return the InputDispenser instance that will be used by the associated activity to create Input factories for each thread slot.default <T> MotorDispenser<T>getMotorDispenser(A activity, InputDispenser inputDispenser, ActionDispenser actionDispenser, OutputDispenser outputDispenser)java.lang.StringgetName()Return the short name of this activity type.default java.util.Optional<OutputDispenser>getOutputDispenser(A activity)This method will be called once per action instance.
-
-
-
Field Detail
-
FINDER
static final SimpleServiceLoader<ActivityType> FINDER
-
-
Method Detail
-
getName
java.lang.String getName()
Return the short name of this activity type. The fully qualified name of an activity type is this value, prefixed by the package of the implementing class.
-
getActivity
default A getActivity(ActivityDef activityDef)
Create an instance of an activity from the activity type.- Parameters:
activityDef- the definition that initializes and controls the activity.- Returns:
- a distinct Activity instance for each call
-
getAssembledActivity
default Activity getAssembledActivity(ActivityDef activityDef, java.util.Map<java.lang.String,Activity> activities)
Create an instance of an activity that ties together all the components into a usable activity instance. This is the method that should be called by executor classes.- Parameters:
activityDef- the definition that initializez and controlls the activity.activities- a map of existing activities- Returns:
- a distinct activity instance for each call
-
getOutputDispenser
default java.util.Optional<OutputDispenser> getOutputDispenser(A activity)
This method will be called once per action instance.- Parameters:
activity- The activity instance that will parameterize the returned MarkerDispenser instance.- Returns:
- an instance of MarkerDispenser
-
getActionDispenser
default ActionDispenser getActionDispenser(A activity)
This method will be called once per action instance.- Parameters:
activity- The activity instance that will parameterize the returned ActionDispenser instance.- Returns:
- an instance of ActionDispenser
-
getInputDispenser
default InputDispenser getInputDispenser(A activity)
Return the InputDispenser instance that will be used by the associated activity to create Input factories for each thread slot.- Parameters:
activity- the Activity instance which will parameterize this InputDispenser- Returns:
- the InputDispenser for the associated activity
-
getMotorDispenser
default <T> MotorDispenser<T> getMotorDispenser(A activity, InputDispenser inputDispenser, ActionDispenser actionDispenser, OutputDispenser outputDispenser)
-
-