
%

%   Copyright 2013 The MathWorks, Inc.

classdef MSUtils < handle
    methods(Static)
        
        % Create new SystemsEngineering.SLGraphVertex object and sets its
        % id (to refer to an existing object)
        function v = graphVertices(vId)
            persistent vertex;
            if isempty(vertex)
                vertex = SystemsEngineering.SLGraphVertex;
            end
            if isempty(vId)
                v = vertex(1:-1);
            else
                v(length(vId)) = vertex;
                for i=1:length(vId)
                    v(i).vId = vId(i);
                end
            end
        end
        
        % Create new SystemsEngineering.SLGraphVertex object and sets its
        % id (to refer to an existing object)
        function e = graphEdges(eId)
            
            persistent edge;
            if isempty(edge)
                edge = SystemsEngineering.SLGraphEdge;
            end
            
            e = edge(1:-1);
            for i=1:length(eId)
                e(end+1) = edge;
                e(end).eId = eId(i);
            end
        end
        
        % Create a set of tree nodes from its IDs
        function n = treeNodes(ids)
            persistent t;
            if isempty(t)
                t = SystemsEngineering.SLSysTreeNode;
            end
            if ~isempty(ids)
                n(length(ids)) = t;
                for i=1:length(ids)
                    n(i).Id = ids(i);
                end
            else
                n = t(1:-1);
            end

        end
        
    end
    
end
