www.gusucode.com > robotsimulink 工具箱 matlab源码程序 > robotsimulink/robotslros/+robotics/+slros/+internal/+bus/VarLenArrayInfo.m
classdef VarLenArrayInfo < handle %This class is for internal use only. It may be removed in the future. % VarLenArrayInfo holds information about a variable-length property, % & and is used when saving and retriving info about maximum sizes of % variable-length arrays. % % See also: bus.VarlenArraySizeStore % Copyright 2014 The MathWorks, Inc. properties (SetAccess=private) MessageType ArrayProps = struct('PropertyName', {}, 'DataType', {}, 'MaxLength', {}) end methods function obj = VarLenArrayInfo(msgtype, varargin) if exist('msgtype', 'var') obj.MessageType = msgtype; if length(varargin) > 1 obj.ArrayProps = ... struct('PropertyName', varargin{1}, 'DataType', varargin{2}, 'MaxLength', varargin{3}); end end end function addArrayProp(obj, s) assert(isstruct(s)); % The use of (end+1) enforces that the fields of S match % expected fields. obj.ArrayProps(end+1) = s; end function out = getMaxLength(obj, index) out = obj.ArrayProps(index).MaxLength; end function setMaxLength(obj, index, value) validateattributes(index, {'numeric'}, {'scalar', 'nonnegative'}); validateattributes(value, {'numeric'}, {'scalar', 'nonnegative'}); obj.ArrayProps(index).MaxLength = value; end function setFromCellArray(obj, propName, values) for i=1:numel(obj.ArrayProps) obj.ArrayProps(i).(propName) = values{i}; end end function s = getPropsStruct(obj) s = obj.ArrayProps; end function setPropsStruct(obj, s) obj.ArrayProps = s; end end methods(Static) function out = extractFromMsgMapInfo(msginfo) out = robotics.slros.internal.bus.VarLenArrayInfo(... msginfo.ROSMessageType, ... msginfo.VarLenArrays, ... msginfo.VarLenDataType, ... msginfo.VarLenMaxLen); end end end