diff m-toolbox/classes/@collection/identifyInsideObjs.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@collection/identifyInsideObjs.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,72 @@
+% 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
+  
+
+
+
+
+