% CODERGROUPSINFO stores CoderGroups information for SIL/PIL to avoid
% accessing CodeDescriptor multiple times
%
%   This is an undocumented class. Its methods and properties are likely to
%   change without warning from one release to the next.

%   Copyright 2017-2019 The MathWorks, Inc.

classdef (Hidden = true) CoderGroupsInfo
    
   properties (SetAccess = immutable)
       Groups
       NumGroups
   end
   
   properties (Dependent)
       ProcessGroups
   end
   
   methods (Access = private)
       function this = CoderGroupsInfo(groups)
           % constructor
           
           this.NumGroups = numel(groups);
           for idx = 1:this.NumGroups
           
               this.Groups(idx).RootTypeName = groups(idx).RootTypeName;

               this.Groups(idx).Name = groups(idx).Name;

               this.Groups(idx).ContainsInstanceSpecificParameter = ...
                   groups(idx).ContainsInstanceSpecificParameter;
           end
       end
   end
       
       
   methods
       function processGroups = get.ProcessGroups(this)
           % get dependent property, true if we need to process any group
           processGroups = this.NumGroups > 0;
       end
   end
   
   
   methods (Static)
       function info = create(groupList)
           % validate argument and call constructor
               validateattributes(groupList, ...
                                  {'mf.zero.Sequence','coder.descriptor.CoderGroupList'}, {}, mfilename('class'));
           
           groups = groupList.toArray;
           
           info = rtw.pil.CoderGroupsInfo(groups);
       end
       
       function info = empty()
           % create empty CoderGroupsInfo
           info = rtw.pil.CoderGroupsInfo([]);
       end
   end
    
end
