www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgprojconnections/prepareImport.m

    function pInt= prepareImport(ProjA,indA,ProjB,indB,doReplace)
%PREPAREIMPORT prepare items for import
%
% prepareImport(ProjA,indA,ProjB,indB,doReplace,pInt)

% Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc.

% Step 1: replace GUIDS for tradeoffs and optims

% sort out ObjectKey in Tradeoff
%   tables are locked and variables use store

IsTradeOff= strcmp(ProjB.Type(indB),'Tradeoff');
pInt= mbcpointer(1,0);
newkeys= guidarray';
for i= indB(IsTradeOff)
    k= replacekey(ProjB.pNode(i).info,ProjB);
    newkeys= [newkeys k];
end

% update sizelocks in tables
IsTable = strcmp(ProjB.Type(indB),'Table');
pTables= ProjB.pData(indB(IsTable));
passign(pTables, pveceval(pTables,@cleanupSizeLocks,newkeys) )
% Sort out any optims
%   variables use store
IsOptim= strcmp(ProjB.Type(indB),'Optimization');
for i= indB(IsOptim)
    [k,pIntOpt] = replacekey(ProjB.pNode(i).info,ProjB);
    newkeys= [newkeys k];
    pInt= [pInt pIntOpt];
end

IsVar = strcmp(ProjB.Type(indB),'Variable');
pVars= ProjB.pData(indB(IsVar));
% clear all unwanted data from variablestore
passign(pVars, pveceval(pVars,@removestoresexcept,newkeys) )

% Step 2: strip down the SFlist and Flist items for tables and normalisers

IsNorm = strcmp(ProjB.Type(indB),'Normalizer');
pNorms= ProjB.pData(indB(IsNorm));
IsFeat = strcmp(ProjB.Type(indB),'Feature');
pFeats= ProjB.pData(indB(IsFeat));

% clean up SFlist and Flist in normalisers
for i= 1:length(pNorms)
    pNorms(i).info= cleanupSFlist(  pNorms(i).info, pFeats, pTables);
end

% clean up SFlist in tables
for i= 1:length(pTables)
    pTables(i).info= cleanupSFlist(  pTables(i).info, pFeats);
end

% Step 3: merge any information already in Project A but needed for other
% items (e.g. GUIDS for other tradeoffs)

% now merge replace info
 for i=1:length(indB)
     if doReplace(i)
         A= ProjA.pData(indA(i));
         B= ProjB.pData(indB(i));
         B.info= merge(B.info,A.info);
     end
 end