www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@abstractnode/pGetUddChildren.m
function uddChildren = pGetUddChildren(node) %PGETUDDCHILDREN Private function. % % UDDCHILDREN = PGETUDDCHILDREN( NODE ) % % This function is explicitly for use in cases where the appropriate UDD % objects are required for the underlying OOP pointers. This function looks % to see if a pre-existing UDD object wrapping the same pointer exists % connected down to the object node. % Copyright 2004-2015 The MathWorks, Inc. % Default output uddChildren = mbcutils.handleArray(0); if node.isNotNull % Get the children of the project object childPointers = children(node.Object); if ~isempty(childPointers) % Find any mbcmodel.response objects connected down from the project uddChildren = iFindConnectedChildren(node, childPointers); % Which responses are missing - indicated by an invalid handle missing = ~ishandle(uddChildren); if any(missing) % Put them in an array of mbcmodel.abstractnode object newChildren = pveceval(childPointers(missing), @constructMBCModel, 'Project', node.Project); % Convert the output cell array to a handle array newChildren = [newChildren{:}]; % Connect to the project for i = 1:numel(newChildren) node.connect(newChildren(i), 'down'); end % Put them back in the array uddChildren(missing) = newChildren; end end end %-------------------------------------------------------------------------- % %-------------------------------------------------------------------------- function out = iFindConnectedChildren(obj, oopPointers) % % This function takes an array of xregpointers and compares them to the % return arguments of pGetPointerInstance on all the objects down 1 from % obj in the UDD hierarchy. This allows an object obj to connect any number % of mbcfoundation.pointerinterface object below it and call this function with % some xregpointers to retrieve exactly the same UDD objects. This allows % the UDD hierarchy to correctly reflect the xregpointer hierarchy. % % This instance of connection is specific to the xreg hierarchy - there may % be a different implementation for cage. out = mbcutils.handleArray(size(oopPointers)); % Firstly get all the mbcfoundation.pointerinterface objects one level below obj uddChildren = obj.find('-depth', 1, '-isa', 'mbcfoundation.pointerinterface'); % Remove me from the list if uddChildren(1) == obj uddChildren(1) = []; end % Did we find anyone if ~isempty(uddChildren) % Then get their xregpointers childPointers = uddChildren.pGetPointerInstance; % Can we find those pointers in the input pointers [found, location] = ismember(oopPointers(:), childPointers); % Put the found objects in the output out(found) = uddChildren(location(found)); end