Changeset 4035 in Sophya for trunk/SophyaLib/TArray/tarray.cc


Ignore:
Timestamp:
Nov 14, 2011, 5:28:25 PM (14 years ago)
Author:
ansari
Message:

1/ modif mineure ds TArray<T>::::ReadASCII() au print level global de BaseArray
2/ Correction bug gestion memoire au niveau des constructeurs de copie TArray/TMatrix/TVector
avec un BaseArray en argument. Ajout argument optionnel bool pack a ces constructeurs
3/ On autorise desormais la creation des objets TArray/TMatrix/TVector par constructeur de
copie sur des objets non alloues

Reza, 14/11/2011

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/TArray/tarray.cc

    r3850 r4035  
    197197  : BaseArray() , mNDBlock(a.mNDBlock)
    198198{
     199  if (a.NbDimensions() == 0)  return;    // Reza-Nov 2011: we allow copy contrsuctor on non allocated arrays 
    199200  string exmsg = "TArray<T>::TArray(const TArray<T>&)";
    200201  if (!UpdateSizes(a, exmsg))  throw( ParmError(exmsg) );
     
    210211  : BaseArray() , mNDBlock(a.mNDBlock, share)
    211212{
    212   if (a.NbDimensions() == 0)  return; 
     213  if (a.NbDimensions() == 0)  return;  // Reza-Nov 2011: we allow copy contrsuctor on non allocated arrays 
    213214  string exmsg = "TArray<T>::TArray(const TArray<T>&, bool)";
    214215  if (!UpdateSizes(a, exmsg))  throw( ParmError(exmsg) );
     
    216217}
    217218
    218 //! Constructor with size and contents copied (after conversion) from a different type TArray
    219 template <class T>
    220 TArray<T>::TArray(const BaseArray& a)
     219//! Constructor with size and contents copied (after conversion) from an array with different data type.
     220/*!
     221  The array size and memory layout are copied from the array \b a, or a packed array is created if \b pack==true.
     222  \param a : original array, to copy sizes and data from
     223  \param pack : if \b true , create a packed array, else same memory layout as \b a.
     224*/
     225template <class T>
     226TArray<T>::TArray(const BaseArray& a, bool pack)
    221227  : BaseArray() , mNDBlock()
    222228{
    223229  if (a.NbDimensions() == 0)  return; 
    224   string exmsg = "TArray<T>::TArray(const BaseArray&)";
    225   if (!UpdateSizes(a, exmsg))  throw( ParmError(exmsg) );
    226   mNDBlock.ReSize(totsize_);   
    227   //  if (a.mInfo) mInfo = new DVList(*(a.mInfo));  - pb protected !
     230  string exmsg = "TArray<T>::TArray(const BaseArray&,bool)";
     231  ReSize(a,pack,false);
    228232  ConvertAndCopyElt(a);
     233  if (a.HasInfoObject()) mInfo = new DVList(*(a.getInfoPointer()));     
    229234}
    230235
     
    16261631  }
    16271632  SetSeq(es);
    1628   cout << "TArray<T>::ReadASCII()/Info: " << n << " elements read from stream "
    1629        << " (Row,Col= " << nr << "," << nc << ")" << endl;
     1633  if (BaseArray::GetPrintLevel()>0)
     1634    cout << "TArray<T>::ReadASCII()/Info: " << n << " elements read from stream "
     1635         << " (Row,Col= " << nr << "," << nc << ")" << endl;
    16301636  return(n);
    16311637}
Note: See TracChangeset for help on using the changeset viewer.