www.gusucode.com > ros 工具箱 matlab源码程序 > ros/+robotics/+ros/+msggen/+gateway_msgs/GatewayInfo.m

    classdef GatewayInfo < robotics.ros.Message
    %GatewayInfo MATLAB implementation of gateway_msgs/GatewayInfo
    %   This class was automatically generated by
    %   robotics.ros.msg.internal.gen.MessageClassGenerator.
    
    %   Copyright 2014-2016 The MathWorks, Inc.
    
    %#ok<*INUSD>
    
    properties (Constant)
        MessageType = 'gateway_msgs/GatewayInfo' % The ROS message type
    end
    
    properties (Constant, Hidden)
        MD5Checksum = 'dd256c395b10a23239961795b562f6bd' % The MD5 Checksum of the message definition
    end
    
    properties (Access = protected)
        JavaMessage % The Java message object
    end
    
    properties (Constant, Access = protected)
        GatewayMsgsRemoteRuleClass = robotics.ros.msg.internal.MessageFactory.getClassForType('gateway_msgs/RemoteRule') % Dispatch to MATLAB class for message type gateway_msgs/RemoteRule
        GatewayMsgsRuleClass = robotics.ros.msg.internal.MessageFactory.getClassForType('gateway_msgs/Rule') % Dispatch to MATLAB class for message type gateway_msgs/Rule
    end
    
    properties (Dependent)
        Name
        Connected
        Ip
        Firewall
        HubNames
        HubUris
        PublicWatchlist
        PublicInterface
        FlippedConnections
        FlipWatchlist
        FlippedInConnections
        PullWatchlist
        PulledConnections
    end
    
    properties (Access = protected)
        Cache = struct('PublicWatchlist', [], 'PublicInterface', [], 'FlippedConnections', [], 'FlipWatchlist', [], 'FlippedInConnections', [], 'PullWatchlist', [], 'PulledConnections', []) % The cache for fast data access
    end
    
    properties (Constant, Hidden)
        PropertyList = {'Connected', 'Firewall', 'FlipWatchlist', 'FlippedConnections', 'FlippedInConnections', 'HubNames', 'HubUris', 'Ip', 'Name', 'PublicInterface', 'PublicWatchlist', 'PullWatchlist', 'PulledConnections'} % List of non-constant message properties
        ROSPropertyList = {'connected', 'firewall', 'flip_watchlist', 'flipped_connections', 'flipped_in_connections', 'hub_names', 'hub_uris', 'ip', 'name', 'public_interface', 'public_watchlist', 'pull_watchlist', 'pulled_connections'} % List of non-constant ROS message properties
    end
    
    methods
        function obj = GatewayInfo(msg)
            %GatewayInfo Construct the message object GatewayInfo
            import com.mathworks.toolbox.robotics.ros.message.MessageInfo;
            
            % Support default constructor
            if nargin == 0
                obj.JavaMessage = obj.createNewJavaMessage;
                return;
            end
            
            % Construct appropriate empty array
            if isempty(msg)
                obj = obj.empty(0,1);
                return;
            end
            
            % Make scalar construction fast
            if isscalar(msg)
                % Check for correct input class
                if ~MessageInfo.compareTypes(msg(1), obj.MessageType)
                    error(message('robotics:ros:message:NoTypeMatch', obj.MessageType, ...
                        char(MessageInfo.getType(msg(1))) ));
                end
                obj.JavaMessage = msg(1);
                return;
            end
            
            % Check that this is a vector of scalar messages. Since this
            % is an object array, use arrayfun to verify.
            if ~all(arrayfun(@isscalar, msg))
                error(message('robotics:ros:message:MessageArraySizeError'));
            end
            
            % Check that all messages in the array have the correct type
            if ~all(arrayfun(@(x) MessageInfo.compareTypes(x, obj.MessageType), msg))
                error(message('robotics:ros:message:NoTypeMatchArray', obj.MessageType));
            end
            
            % Construct array of objects if necessary
            objType = class(obj);
            for i = 1:length(msg)
                obj(i,1) = feval(objType, msg(i)); %#ok<AGROW>
            end
        end
        
        function name = get.Name(obj)
            %get.Name Get the value for property Name
            name = char(obj.JavaMessage.getName);
        end
        
        function set.Name(obj, name)
            %set.Name Set the value for property Name
            validateattributes(name, {'char'}, {}, 'GatewayInfo', 'Name');
            
            obj.JavaMessage.setName(name);
        end
        
        function connected = get.Connected(obj)
            %get.Connected Get the value for property Connected
            connected = logical(obj.JavaMessage.getConnected);
        end
        
        function set.Connected(obj, connected)
            %set.Connected Set the value for property Connected
            validateattributes(connected, {'logical', 'numeric'}, {'nonempty', 'scalar'}, 'GatewayInfo', 'Connected');
            
            obj.JavaMessage.setConnected(connected);
        end
        
        function ip = get.Ip(obj)
            %get.Ip Get the value for property Ip
            ip = char(obj.JavaMessage.getIp);
        end
        
        function set.Ip(obj, ip)
            %set.Ip Set the value for property Ip
            validateattributes(ip, {'char'}, {}, 'GatewayInfo', 'Ip');
            
            obj.JavaMessage.setIp(ip);
        end
        
        function firewall = get.Firewall(obj)
            %get.Firewall Get the value for property Firewall
            firewall = logical(obj.JavaMessage.getFirewall);
        end
        
        function set.Firewall(obj, firewall)
            %set.Firewall Set the value for property Firewall
            validateattributes(firewall, {'logical', 'numeric'}, {'nonempty', 'scalar'}, 'GatewayInfo', 'Firewall');
            
            obj.JavaMessage.setFirewall(firewall);
        end
        
        function hubnames = get.HubNames(obj)
            %get.HubNames Get the value for property HubNames
            javaArray = obj.JavaMessage.getHubNames;
            array = obj.readJavaArray(javaArray, 'char');
            hubnames = arrayfun(@(x) char(x), array, 'UniformOutput', false);
        end
        
        function set.HubNames(obj, hubnames)
            %set.HubNames Set the value for property HubNames
            if ~isvector(hubnames) && isempty(hubnames)
                % Allow empty [] input
                hubnames = cell.empty(0,1);
            end
            
            validateattributes(hubnames, {'cell'}, {'vector'}, 'GatewayInfo', 'HubNames');
            if any(cellfun(@(x) ~ischar(x), hubnames))
                error(message('robotics:ros:message:CellArrayStringError', ...
                    'hubnames'));
            end
            
            javaArray = obj.JavaMessage.getHubNames;
            array = obj.writeJavaArray(hubnames, javaArray, 'char');
            obj.JavaMessage.setHubNames(array);
        end
        
        function huburis = get.HubUris(obj)
            %get.HubUris Get the value for property HubUris
            javaArray = obj.JavaMessage.getHubUris;
            array = obj.readJavaArray(javaArray, 'char');
            huburis = arrayfun(@(x) char(x), array, 'UniformOutput', false);
        end
        
        function set.HubUris(obj, huburis)
            %set.HubUris Set the value for property HubUris
            if ~isvector(huburis) && isempty(huburis)
                % Allow empty [] input
                huburis = cell.empty(0,1);
            end
            
            validateattributes(huburis, {'cell'}, {'vector'}, 'GatewayInfo', 'HubUris');
            if any(cellfun(@(x) ~ischar(x), huburis))
                error(message('robotics:ros:message:CellArrayStringError', ...
                    'huburis'));
            end
            
            javaArray = obj.JavaMessage.getHubUris;
            array = obj.writeJavaArray(huburis, javaArray, 'char');
            obj.JavaMessage.setHubUris(array);
        end
        
        function publicwatchlist = get.PublicWatchlist(obj)
            %get.PublicWatchlist Get the value for property PublicWatchlist
            if isempty(obj.Cache.PublicWatchlist)
                javaArray = obj.JavaMessage.getPublicWatchlist;
                array = obj.readJavaArray(javaArray, obj.GatewayMsgsRuleClass);
                obj.Cache.PublicWatchlist = feval(obj.GatewayMsgsRuleClass, array);
            end
            publicwatchlist = obj.Cache.PublicWatchlist;
        end
        
        function set.PublicWatchlist(obj, publicwatchlist)
            %set.PublicWatchlist Set the value for property PublicWatchlist
            if ~isvector(publicwatchlist) && isempty(publicwatchlist)
                % Allow empty [] input
                publicwatchlist = feval([obj.GatewayMsgsRuleClass '.empty'], 0, 1);
            end
            
            validateattributes(publicwatchlist, {obj.GatewayMsgsRuleClass}, {'vector'}, 'GatewayInfo', 'PublicWatchlist');
            
            javaArray = obj.JavaMessage.getPublicWatchlist;
            array = obj.writeJavaArray(publicwatchlist, javaArray, obj.GatewayMsgsRuleClass);
            obj.JavaMessage.setPublicWatchlist(array);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.PublicWatchlist)
                obj.Cache.PublicWatchlist = [];
                obj.Cache.PublicWatchlist = obj.PublicWatchlist;
            end
        end
        
        function publicinterface = get.PublicInterface(obj)
            %get.PublicInterface Get the value for property PublicInterface
            if isempty(obj.Cache.PublicInterface)
                javaArray = obj.JavaMessage.getPublicInterface;
                array = obj.readJavaArray(javaArray, obj.GatewayMsgsRuleClass);
                obj.Cache.PublicInterface = feval(obj.GatewayMsgsRuleClass, array);
            end
            publicinterface = obj.Cache.PublicInterface;
        end
        
        function set.PublicInterface(obj, publicinterface)
            %set.PublicInterface Set the value for property PublicInterface
            if ~isvector(publicinterface) && isempty(publicinterface)
                % Allow empty [] input
                publicinterface = feval([obj.GatewayMsgsRuleClass '.empty'], 0, 1);
            end
            
            validateattributes(publicinterface, {obj.GatewayMsgsRuleClass}, {'vector'}, 'GatewayInfo', 'PublicInterface');
            
            javaArray = obj.JavaMessage.getPublicInterface;
            array = obj.writeJavaArray(publicinterface, javaArray, obj.GatewayMsgsRuleClass);
            obj.JavaMessage.setPublicInterface(array);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.PublicInterface)
                obj.Cache.PublicInterface = [];
                obj.Cache.PublicInterface = obj.PublicInterface;
            end
        end
        
        function flippedconnections = get.FlippedConnections(obj)
            %get.FlippedConnections Get the value for property FlippedConnections
            if isempty(obj.Cache.FlippedConnections)
                javaArray = obj.JavaMessage.getFlippedConnections;
                array = obj.readJavaArray(javaArray, obj.GatewayMsgsRemoteRuleClass);
                obj.Cache.FlippedConnections = feval(obj.GatewayMsgsRemoteRuleClass, array);
            end
            flippedconnections = obj.Cache.FlippedConnections;
        end
        
        function set.FlippedConnections(obj, flippedconnections)
            %set.FlippedConnections Set the value for property FlippedConnections
            if ~isvector(flippedconnections) && isempty(flippedconnections)
                % Allow empty [] input
                flippedconnections = feval([obj.GatewayMsgsRemoteRuleClass '.empty'], 0, 1);
            end
            
            validateattributes(flippedconnections, {obj.GatewayMsgsRemoteRuleClass}, {'vector'}, 'GatewayInfo', 'FlippedConnections');
            
            javaArray = obj.JavaMessage.getFlippedConnections;
            array = obj.writeJavaArray(flippedconnections, javaArray, obj.GatewayMsgsRemoteRuleClass);
            obj.JavaMessage.setFlippedConnections(array);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.FlippedConnections)
                obj.Cache.FlippedConnections = [];
                obj.Cache.FlippedConnections = obj.FlippedConnections;
            end
        end
        
        function flipwatchlist = get.FlipWatchlist(obj)
            %get.FlipWatchlist Get the value for property FlipWatchlist
            if isempty(obj.Cache.FlipWatchlist)
                javaArray = obj.JavaMessage.getFlipWatchlist;
                array = obj.readJavaArray(javaArray, obj.GatewayMsgsRemoteRuleClass);
                obj.Cache.FlipWatchlist = feval(obj.GatewayMsgsRemoteRuleClass, array);
            end
            flipwatchlist = obj.Cache.FlipWatchlist;
        end
        
        function set.FlipWatchlist(obj, flipwatchlist)
            %set.FlipWatchlist Set the value for property FlipWatchlist
            if ~isvector(flipwatchlist) && isempty(flipwatchlist)
                % Allow empty [] input
                flipwatchlist = feval([obj.GatewayMsgsRemoteRuleClass '.empty'], 0, 1);
            end
            
            validateattributes(flipwatchlist, {obj.GatewayMsgsRemoteRuleClass}, {'vector'}, 'GatewayInfo', 'FlipWatchlist');
            
            javaArray = obj.JavaMessage.getFlipWatchlist;
            array = obj.writeJavaArray(flipwatchlist, javaArray, obj.GatewayMsgsRemoteRuleClass);
            obj.JavaMessage.setFlipWatchlist(array);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.FlipWatchlist)
                obj.Cache.FlipWatchlist = [];
                obj.Cache.FlipWatchlist = obj.FlipWatchlist;
            end
        end
        
        function flippedinconnections = get.FlippedInConnections(obj)
            %get.FlippedInConnections Get the value for property FlippedInConnections
            if isempty(obj.Cache.FlippedInConnections)
                javaArray = obj.JavaMessage.getFlippedInConnections;
                array = obj.readJavaArray(javaArray, obj.GatewayMsgsRemoteRuleClass);
                obj.Cache.FlippedInConnections = feval(obj.GatewayMsgsRemoteRuleClass, array);
            end
            flippedinconnections = obj.Cache.FlippedInConnections;
        end
        
        function set.FlippedInConnections(obj, flippedinconnections)
            %set.FlippedInConnections Set the value for property FlippedInConnections
            if ~isvector(flippedinconnections) && isempty(flippedinconnections)
                % Allow empty [] input
                flippedinconnections = feval([obj.GatewayMsgsRemoteRuleClass '.empty'], 0, 1);
            end
            
            validateattributes(flippedinconnections, {obj.GatewayMsgsRemoteRuleClass}, {'vector'}, 'GatewayInfo', 'FlippedInConnections');
            
            javaArray = obj.JavaMessage.getFlippedInConnections;
            array = obj.writeJavaArray(flippedinconnections, javaArray, obj.GatewayMsgsRemoteRuleClass);
            obj.JavaMessage.setFlippedInConnections(array);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.FlippedInConnections)
                obj.Cache.FlippedInConnections = [];
                obj.Cache.FlippedInConnections = obj.FlippedInConnections;
            end
        end
        
        function pullwatchlist = get.PullWatchlist(obj)
            %get.PullWatchlist Get the value for property PullWatchlist
            if isempty(obj.Cache.PullWatchlist)
                javaArray = obj.JavaMessage.getPullWatchlist;
                array = obj.readJavaArray(javaArray, obj.GatewayMsgsRemoteRuleClass);
                obj.Cache.PullWatchlist = feval(obj.GatewayMsgsRemoteRuleClass, array);
            end
            pullwatchlist = obj.Cache.PullWatchlist;
        end
        
        function set.PullWatchlist(obj, pullwatchlist)
            %set.PullWatchlist Set the value for property PullWatchlist
            if ~isvector(pullwatchlist) && isempty(pullwatchlist)
                % Allow empty [] input
                pullwatchlist = feval([obj.GatewayMsgsRemoteRuleClass '.empty'], 0, 1);
            end
            
            validateattributes(pullwatchlist, {obj.GatewayMsgsRemoteRuleClass}, {'vector'}, 'GatewayInfo', 'PullWatchlist');
            
            javaArray = obj.JavaMessage.getPullWatchlist;
            array = obj.writeJavaArray(pullwatchlist, javaArray, obj.GatewayMsgsRemoteRuleClass);
            obj.JavaMessage.setPullWatchlist(array);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.PullWatchlist)
                obj.Cache.PullWatchlist = [];
                obj.Cache.PullWatchlist = obj.PullWatchlist;
            end
        end
        
        function pulledconnections = get.PulledConnections(obj)
            %get.PulledConnections Get the value for property PulledConnections
            if isempty(obj.Cache.PulledConnections)
                javaArray = obj.JavaMessage.getPulledConnections;
                array = obj.readJavaArray(javaArray, obj.GatewayMsgsRemoteRuleClass);
                obj.Cache.PulledConnections = feval(obj.GatewayMsgsRemoteRuleClass, array);
            end
            pulledconnections = obj.Cache.PulledConnections;
        end
        
        function set.PulledConnections(obj, pulledconnections)
            %set.PulledConnections Set the value for property PulledConnections
            if ~isvector(pulledconnections) && isempty(pulledconnections)
                % Allow empty [] input
                pulledconnections = feval([obj.GatewayMsgsRemoteRuleClass '.empty'], 0, 1);
            end
            
            validateattributes(pulledconnections, {obj.GatewayMsgsRemoteRuleClass}, {'vector'}, 'GatewayInfo', 'PulledConnections');
            
            javaArray = obj.JavaMessage.getPulledConnections;
            array = obj.writeJavaArray(pulledconnections, javaArray, obj.GatewayMsgsRemoteRuleClass);
            obj.JavaMessage.setPulledConnections(array);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.PulledConnections)
                obj.Cache.PulledConnections = [];
                obj.Cache.PulledConnections = obj.PulledConnections;
            end
        end
    end
    
    methods (Access = protected)
        function resetCache(obj)
            %resetCache Resets any cached properties
            obj.Cache.PublicWatchlist = [];
            obj.Cache.PublicInterface = [];
            obj.Cache.FlippedConnections = [];
            obj.Cache.FlipWatchlist = [];
            obj.Cache.FlippedInConnections = [];
            obj.Cache.PullWatchlist = [];
            obj.Cache.PulledConnections = [];
        end
        
        function cpObj = copyElement(obj)
            %copyElement Implements deep copy behavior for message
            
            % Call default copy method for shallow copy
            cpObj = copyElement@robotics.ros.Message(obj);
            
            % Clear any existing cached properties
            cpObj.resetCache;
            
            % Create a new Java message object
            cpObj.JavaMessage = obj.createNewJavaMessage;
            
            % Iterate over all primitive properties
            cpObj.Name = obj.Name;
            cpObj.Connected = obj.Connected;
            cpObj.Ip = obj.Ip;
            cpObj.Firewall = obj.Firewall;
            cpObj.HubNames = obj.HubNames;
            cpObj.HubUris = obj.HubUris;
            
            % Recursively copy compound properties
            cpObj.PublicWatchlist = copy(obj.PublicWatchlist);
            cpObj.PublicInterface = copy(obj.PublicInterface);
            cpObj.FlippedConnections = copy(obj.FlippedConnections);
            cpObj.FlipWatchlist = copy(obj.FlipWatchlist);
            cpObj.FlippedInConnections = copy(obj.FlippedInConnections);
            cpObj.PullWatchlist = copy(obj.PullWatchlist);
            cpObj.PulledConnections = copy(obj.PulledConnections);
        end
        
        function reload(obj, strObj)
            %reload Called by loadobj to assign properties
            obj.Name = strObj.Name;
            obj.Connected = strObj.Connected;
            obj.Ip = strObj.Ip;
            obj.Firewall = strObj.Firewall;
            obj.HubNames = strObj.HubNames;
            obj.HubUris = strObj.HubUris;
            PublicWatchlistCell = arrayfun(@(x) feval([obj.GatewayMsgsRuleClass '.loadobj'], x), strObj.PublicWatchlist, 'UniformOutput', false);
            obj.PublicWatchlist = vertcat(PublicWatchlistCell{:});
            PublicInterfaceCell = arrayfun(@(x) feval([obj.GatewayMsgsRuleClass '.loadobj'], x), strObj.PublicInterface, 'UniformOutput', false);
            obj.PublicInterface = vertcat(PublicInterfaceCell{:});
            FlippedConnectionsCell = arrayfun(@(x) feval([obj.GatewayMsgsRemoteRuleClass '.loadobj'], x), strObj.FlippedConnections, 'UniformOutput', false);
            obj.FlippedConnections = vertcat(FlippedConnectionsCell{:});
            FlipWatchlistCell = arrayfun(@(x) feval([obj.GatewayMsgsRemoteRuleClass '.loadobj'], x), strObj.FlipWatchlist, 'UniformOutput', false);
            obj.FlipWatchlist = vertcat(FlipWatchlistCell{:});
            FlippedInConnectionsCell = arrayfun(@(x) feval([obj.GatewayMsgsRemoteRuleClass '.loadobj'], x), strObj.FlippedInConnections, 'UniformOutput', false);
            obj.FlippedInConnections = vertcat(FlippedInConnectionsCell{:});
            PullWatchlistCell = arrayfun(@(x) feval([obj.GatewayMsgsRemoteRuleClass '.loadobj'], x), strObj.PullWatchlist, 'UniformOutput', false);
            obj.PullWatchlist = vertcat(PullWatchlistCell{:});
            PulledConnectionsCell = arrayfun(@(x) feval([obj.GatewayMsgsRemoteRuleClass '.loadobj'], x), strObj.PulledConnections, 'UniformOutput', false);
            obj.PulledConnections = vertcat(PulledConnectionsCell{:});
        end
    end
    
    methods (Access = ?robotics.ros.Message)
        function strObj = saveobj(obj)
            %saveobj Implements saving of message to MAT file
            
            % Return an empty element if object array is empty
            if isempty(obj)
                strObj = struct.empty;
                return
            end
            
            strObj.Name = obj.Name;
            strObj.Connected = obj.Connected;
            strObj.Ip = obj.Ip;
            strObj.Firewall = obj.Firewall;
            strObj.HubNames = obj.HubNames;
            strObj.HubUris = obj.HubUris;
            strObj.PublicWatchlist = arrayfun(@(x) saveobj(x), obj.PublicWatchlist);
            strObj.PublicInterface = arrayfun(@(x) saveobj(x), obj.PublicInterface);
            strObj.FlippedConnections = arrayfun(@(x) saveobj(x), obj.FlippedConnections);
            strObj.FlipWatchlist = arrayfun(@(x) saveobj(x), obj.FlipWatchlist);
            strObj.FlippedInConnections = arrayfun(@(x) saveobj(x), obj.FlippedInConnections);
            strObj.PullWatchlist = arrayfun(@(x) saveobj(x), obj.PullWatchlist);
            strObj.PulledConnections = arrayfun(@(x) saveobj(x), obj.PulledConnections);
        end
    end
    
    methods (Static, Access = {?matlab.unittest.TestCase, ?robotics.ros.Message})
        function obj = loadobj(strObj)
            %loadobj Implements loading of message from MAT file
            
            % Return an empty object array if the structure element is not defined
            if isempty(strObj)
                obj = robotics.ros.msggen.gateway_msgs.GatewayInfo.empty(0,1);
                return
            end
            
            % Create an empty message object
            obj = robotics.ros.msggen.gateway_msgs.GatewayInfo;
            obj.reload(strObj);
        end
    end
end