view m-toolbox/classes/@ssmblock/getPortsWithName.m @ 45:a59cdb8aaf31 database-connection-manager

Merge
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 19:07:22 +0100
parents f0afece42f48
children
line wrap: on
line source

% GETPORTSWITHNAME get all ports with the matching name.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: GETPORTSWITHNAME get all ports with the matching name.
%
% CALL:            ports = getPortsWithName(ssmblocks, name)
%       [ports, indices] = getPortsWithName(ssmblocks, plist('name', aName))
%
% VERSION:     $Id: getPortsWithName.m,v 1.6 2011/04/08 08:56:31 hewitson Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = getPortsWithName(varargin)
  error('This function is deprecated and will be deleted')
  
  [objs, in_vars, rest] = utils.helper.collect_objects(varargin(:), 'ssmblock');
  [pl, in_vars, rest] = utils.helper.collect_objects(rest, 'plist');
  
  ports   = [];
  indices = {};
  
  
  if isa(pl, 'plist')
    name = pl.find('name');
  end
  for kk=1:numel(rest)
    if ischar(rest{kk})
      name = rest{kk};
    end
  end
  
  for kk=1:numel(objs)
    idx = strcmpi(name, {objs(kk).ports.name});
    ports   = [ports objs(kk).ports(idx)];
    indices = [indices {find(idx)}];
  end
  
  if nargout == 1
    varargout{1} = ports;
  elseif nargout == 2
    varargout{1} = ports;
    varargout{2} = indices;
  end
  
end