view m-toolbox/classes/@collection/identifyInsideObjs.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
line source

% identifyInsideObjs Static method which identify the inside objects and configuration PLISTs.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: identifyInsideObjs Static method which identify the inside
%              objects and configuration PLISTs. The input must be a
%              cell-array.
%
% CALL:        [objs, plConfig] = identifyInsideObjs(objsIn)
%
% INPUT:       objsIn:   Cell-array, for example varargin{:}
%
% OUTPUTS:     objs:     Objects which should go into the collection
%              plConfig: Configuration PLIST.
%
% VERSION:     $Id: identifyInsideObjs.m,v 1.2 2010/06/24 14:19:33 ingo Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [objs, plConfig] = identifyInsideObjs(objsIn)
  
  plConfig = plist();
  objs = {};
  
  % Make sure that the objsIn is a cell-array
  if ~iscell(objsIn)
    objsIn = num2cell(objsIn);
  end
  
  % Loop over all inputs
  for oo = 1:numel(objsIn)
    
    if isa(objsIn{oo}, 'plist')
      pls = objsIn{oo};
      % PLISTS with the key 'ignore' and the value true are NO configuration
      % PLISTS
      for ii = 1:numel(pls)
        if shouldIgnore(pls(ii))
          %%% This is not a configuration PLIST. Put it to the inside objects.
          objs = [objs, {pls(ii)}];
        else
          %%% This is a configuration PLIST.
          objsInPlist = pls(ii).find('objs');
          if ~isempty(objsInPlist)
            % Found objects for the collection inside the PLIST. Add this
            % objects to the collection objects.
            if iscell(objsInPlist)
              objs = [objs, reshape(objsInPlist, 1, [])];
            else
              objs = [objs, num2cell(reshape(objsInPlist, 1, []))];
            end
          end
          plConfig = combine(pls(ii), plConfig);
        end
      end
      
    else
      objs = [objs, num2cell(reshape(objsIn{oo}, 1, []))];
    end
    
  end % for
  
  % Remove the key 'objs' from the configuration PLIST
  if plConfig.isparam('objs')
    plConfig.remove('objs');
  end
  
end