Changeset 24f03be in tol


Ignore:
Timestamp:
Jul 20, 2009, 9:03:57 AM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
64231ec
Parents:
cb1355f
Message:

DeepCopy will call BCode::Replicate to create a new object independent from original one

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1173 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/set_type/setgra.cpp

    rcb1355f r24f03be  
    20972097
    20982098//--------------------------------------------------------------------
     2099BSyntaxObject* CopyCode(BSyntaxObject* obj)
     2100{
     2101  BCode cod;
     2102  cod.Replicate(Code(obj));
     2103  return(new BContensCode("",cod,""));
     2104};
     2105/*
     2106//--------------------------------------------------------------------
     2107BSyntaxObject* CopyNameBlock(BSyntaxObject* obj,const BArray<BDat>& p,BInt& pos)
     2108{
     2109  BUseerNameBlock* unb = (BUseerNameBlock*)obj
     2110  BNameBlock mat = unb->Contens();
     2111  if(p.Size())
     2112  {
     2113          for(BInt i=0; i<mat.Rows(); i++)
     2114          {
     2115            for(BInt j=0; j<mat.Columns(); j++)
     2116            {
     2117                mat(i,j) = p[pos++];
     2118            }
     2119        }
     2120    }
     2121    return(new BContensMat("",mat,""));
     2122};
     2123*/
     2124
     2125//--------------------------------------------------------------------
    20992126BSyntaxObject* CopySet(BSyntaxObject* obj,const BArray<BDat>& p,BInt& pos);
    21002127
    … …  
    21022129void DeepCopy(const BSet& sample,BSet& copy,const BArray<BDat>& p,BInt& pos)
    21032130{
    2104     BList* lst = NIL;
    2105     BList* aux = NIL;
    2106     BInt i;
    2107     for(i=1; i<=sample.Card(); i++)
    2108     {
    2109         if(sample[i])
    2110         {
    2111             BSyntaxObject* obj = NIL;
    2112             BGrammar*        gra = sample[i]->Grammar();
    2113             if(gra==GraReal   ())      { obj = CopyReal   (sample[i],p,pos); }
    2114             else if(gra==GraPolyn  ()) { obj = CopyPolyn  (sample[i],p,pos); }
    2115             else if(gra==GraRatio ()) { obj = CopyRatio (sample[i],p,pos); }
    2116             else if(gra==GraMatrix ()) { obj = CopyMatrix (sample[i],p,pos); }
    2117             else if(gra==GraSet    ()) { obj = CopySet    (sample[i],p,pos); }
    2118             else                       { obj = sample[i]->CopyContens ();    }
    2119             LstFastAppend(lst,aux,obj);
    2120         }
    2121     }
    2122     copy.RobStruct(lst,sample.Struct(),sample.SubType());
     2131  BList* lst = NIL;
     2132  BList* aux = NIL;
     2133  BInt i;
     2134  for(i=1; i<=sample.Card(); i++)
     2135  {
     2136    if(sample[i])
     2137    {
     2138      BSyntaxObject* obj = NIL;
     2139      BGrammar*      gra = sample[i]->Grammar();
     2140           if(gra==GraReal   ()) { obj = CopyReal   (sample[i],p,pos); }
     2141      else if(gra==GraPolyn  ()) { obj = CopyPolyn  (sample[i],p,pos); }
     2142      else if(gra==GraRatio  ()) { obj = CopyRatio  (sample[i],p,pos); }
     2143      else if(gra==GraMatrix ()) { obj = CopyMatrix (sample[i],p,pos); }
     2144      else if(gra==GraSet    ()) { obj = CopySet    (sample[i],p,pos); }
     2145      else if(gra==GraCode   ()) { obj = CopyCode   (sample[i]);       }
     2146      else                                 { obj = sample[i]->CopyContens ();    }
     2147      if(obj && !obj->HasName())
     2148      {
     2149        obj->PutName(sample[i]->Name());
     2150      }
     2151      LstFastAppend(lst,aux,obj);
     2152    }
     2153  }
     2154  copy.RobStruct(lst,sample.Struct(),sample.SubType());
     2155  if(sample.HasIndexByName())
     2156  {
     2157    copy.SetIndexByName();
     2158  }
    21232159};
     2160
    21242161
    21252162//--------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.