classdef StrategyFactory
    %% STRATEGYFACTORY class
    % This is a factory class to interpret the user intent to a strategy
    % used for updating the DesignStore
    
    % Copyright 2018-2021 The MathWorks, Inc.
    
    methods(Static)
        
        function strategy = getStrategy(context)
            
            % extract the intent from the context object
            userIntent = context.Intent;
            
            if userIntent == fxptds.UserIntent.OpenModel
                % user has opened FPT
                strategy = fxptds.WorkflowTopology.ModelInitializationStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.RenameModel
                % user has saved the model as a different name
                strategy = fxptds.WorkflowTopology.ModelRenameStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.DeclareWorkflow
                % user has decided which workflow to start
                strategy = fxptds.WorkflowTopology.DeclareWorkflowStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.PrepareModel
                % user has begun the prepare step with Analyzer
                strategy = fxptds.WorkflowTopology.PrepareStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.DeleteRun
                % user has deleted a run
                strategy = fxptds.WorkflowTopology.DeleteRunStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.DeriveMinMax
                % user has run Derived Range Analysis
                strategy = fxptds.WorkflowTopology.DeriveStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.SimpleSimulation
                % user has collected ranges
                strategy = fxptds.WorkflowTopology.SimpleSimulationStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.MergeSimulation
                % user has simulated AND selected merge min/max
                strategy = fxptds.WorkflowTopology.MergeSimulationStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.AutoscalerProposal
                % user has proposed DT
                strategy = fxptds.WorkflowTopology.AutoscalerProposeStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.AutoscalerApply
                % user has accepted the proposed DT
                strategy = fxptds.WorkflowTopology.AutoscalerApplyStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.AutoscalerVerification
                % user has simulated embedded types
                strategy = fxptds.WorkflowTopology.AutoscalerVerifyStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.OptimizedConversion
                % user has initiated fxpopt to produce a result
                strategy = fxptds.WorkflowTopology.OptimizedConversionStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.OptimizationApplySolution
                % user has applied a solution from fxpopt
                strategy = fxptds.WorkflowTopology.OptimizationApplySolutionStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.CollectionVerification
                % user wants to verify a baseline collection
                strategy = fxptds.WorkflowTopology.CollectionVerificationStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.UpdateContainer
                % user wants to verify a baseline collection
                strategy = fxptds.WorkflowTopology.ReassignContainerStrategy(context);
            elseif userIntent ==  fxptds.UserIntent.StartOptimization
                % user wants to start a new action
                strategy = fxptds.WorkflowTopology.InvalidateNodesStrategy(context);
            else
                % no-op strategy
                strategy = fxptds.WorkflowTopology.NullStrategy(context);
            end
            
        end
        
        function strategy = getQueryStrategy(context)
            strategy = fxptds.WorkflowTopology.QueryStrategy(context);
        end
        
    end
end

