classdef (Hidden = true) ExecutionSet < handle
    %EXECUTIONSET is the base class for storing profiling results

    %   Copyright 2023 The MathWorks, Inc.
    
    properties (GetAccess = public, SetAccess = private, Hidden)
        % model or MATLAB file the code was generated from
        ComponentUnderTest;
        % timestamp when this object was created
        TimeCreated;
    end
    
    properties (Access = public)
        % number of longest execution to select for test
        ResultsPerTest = 5;
    end

    methods(Access=public)
        function obj = ExecutionSet(componentUnderTest)
            obj.ComponentUnderTest = componentUnderTest;
            obj.TimeCreated = string(datetime("now"));
        end

        function disp(this)
            % print link to Code Profile Analyzer
            
            thisObjName = inputname(1);
            intro = message('CoderProfile:Test:SetDispIntro', ...
                this.ComponentUnderTest).getString();
            mLink = sprintf('<a href="matlab: coder.profile.show(%s)">coder.profile.show(%s)</a>', ...
                thisObjName, thisObjName);
            cmdHyperlink = message('CoderProfile:Test:SetDispLink', mLink).getString();
            disp(intro);
            disp(cmdHyperlink);
            disp(' ');
        end
    end

    methods
        function set.ResultsPerTest(this, v)
            arguments
                this
                v (1,1) double {mustBeInteger, mustBeFinite, mustBeReal, mustBeGreaterThanOrEqual(v, 1)}
            end
            this.ResultsPerTest = v;
        end
    end

    methods(Access=public, Abstract)
        % append a result to the set
        add(this, testname, ex);
        % get a result from the set
        ex = get(this, testname);
        % remove a result from the set
        remove(this, testname);
    end

    methods(Access=public, Hidden, Abstract)
        res = getSummaryInfo(this);
    end
end
