Changeset 979 in Sophya


Ignore:
Timestamp:
Apr 28, 2000, 4:09:46 PM (25 years ago)
Author:
ansari
Message:

modifs constructeurs copie et operateur =

Location:
trunk/SophyaLib/SkyMap
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SkyMap/localmap.cc

    r908 r979  
    6565//++
    6666template<class T>
    67 LocalMap<T>::LocalMap()
     67LocalMap<T>::LocalMap() :  pixels_()
    6868//
    6969//     
     
    7171{
    7272  InitNul();
    73   pixels_.Reset();
     73  //  pixels_.Reset();
    7474}
    7575
     
    148148}
    149149
     150////////////////////////// methodes de copie/share
     151
     152template<class T>
     153void LocalMap<T>::CloneOrShare(const LocalMap<T>& a)
     154{
     155      recopierVariablesSimples(a);     
     156      pixels_.CloneOrShare(a.pixels_);
     157}
     158
     159template<class T>
     160LocalMap<T>& LocalMap<T>::CopyElt(const LocalMap<T>& a)
     161{
     162  if (NbPixels() < 1)
     163    throw RangeCheckError("LocalMap<T>::CopyElt(const LocalMap<T>& )  - Not Allocated Array ! ");
     164  if (NbPixels() != a.NbPixels())
     165    throw(SzMismatchError("LocalMap<T>::CopyElt(const LocalMap<T>&) SizeMismatch")) ;
     166      recopierVariablesSimples(a);     
     167  int k;
     168  for (k=0; k< nPix_; k++) pixels_(k) = a.pixels_(k);
     169  return(*this);
     170
     171}
     172
    150173template<class T>
    151174LocalMap<T>& LocalMap<T>::Set(const LocalMap<T>& a)
     
    153176  if (this != &a)
    154177    {
    155       recopierVariablesSimples(a);     
    156       pixels_.CloneOrShare(a.pixels_);
     178      if (a.NbPixels() < 1)
     179        throw RangeCheckError("LocalMap<T>::Set(a ) - Array a not allocated ! ");
     180      if (NbPixels() < 1) CloneOrShare(a);
     181      else CopyElt(a);
    157182      if (mInfo_) delete mInfo_;
    158183      mInfo_ = NULL;
  • trunk/SophyaLib/SkyMap/localmap.h

    r917 r979  
    198198void recopierVariablesSimples(const LocalMap<T>& lm);
    199199LocalMap<T>& Set(const LocalMap<T>& a);
     200void CloneOrShare(const LocalMap<T>& a);
     201  LocalMap<T>& CopyElt(const LocalMap<T>& a);
    200202
    201203
  • trunk/SophyaLib/SkyMap/spherehealpix.cc

    r965 r979  
    177177
    178178template<class T>
    179 SphereHEALPix<T>::SphereHEALPix()
     179SphereHEALPix<T>::SphereHEALPix() : pixels_(), sliceBeginIndex_(),
     180                                                sliceLenght_()
    180181
    181182//--
    182183{
    183184  InitNul();
    184   pixels_.Reset();
     185  //  SetTemp(false);
    185186}
    186187
     
    211212    }
    212213  InitNul();
     214  //  SetTemp(false);
    213215  Pixelize(m);
    214216  SetThetaSlices();
     
    222224//--
    223225{
    224   if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
    225 
    226226  nSide_= s.nSide_;
    227227  nPix_ = s.nPix_;
    228228  omeg_ = s.omeg_;
     229  if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
    229230}
    230231//++
     
    236237//--
    237238{
    238   if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
    239 
    240239  nSide_= s.nSide_;
    241240  nPix_ = s.nPix_;
    242241  omeg_ = s.omeg_;
     242  if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
     243  //  CloneOrShare(s);
    243244}
    244245
     
    246247void SphereHEALPix<T>::CloneOrShare(const SphereHEALPix<T>& a)
    247248{
     249  nSide_= a.nSide_;
     250  nPix_ = a.nPix_;
     251  omeg_ = a.omeg_;
    248252  pixels_.CloneOrShare(a.pixels_);
    249253  sliceBeginIndex_.CloneOrShare(a.sliceBeginIndex_);
    250254  sliceLenght_.CloneOrShare(a.sliceLenght_);
    251 }
    252 
     255
     256  // pas forcement a conserver, pas forcement a cet endroit (GLM)
     257  //  if (a.IsTemp() ) SetTemp(true);
     258}
     259
     260////////////////////////// methodes de copie/share
    253261template<class T>
    254262SphereHEALPix<T>& SphereHEALPix<T>::Set(const SphereHEALPix<T>& a)
     
    256264  if (this != &a)
    257265    {
    258       nSide_= a.nSide_;
    259      nPix_ = a.nPix_;
    260      omeg_ = a.omeg_;
    261      CloneOrShare(a);
     266
     267  if (a.NbPixels() < 1)
     268    throw RangeCheckError("SphereHEALPix<T>::Set(a ) - Array a not allocated ! ");
     269  if (NbPixels() < 1) CloneOrShare(a);
     270  else CopyElt(a);
     271
     272
     273      //     CloneOrShare(a);
    262274     if (mInfo_) delete mInfo_;
    263275     mInfo_ = NULL;
     
    267279   }
    268280
    269 
     281template<class T>
     282SphereHEALPix<T>& SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>& a)
     283{
     284  if (NbPixels() < 1)
     285    throw RangeCheckError("SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>& )  - Not Allocated Array ! ");
     286  if (NbPixels() != a.NbPixels())
     287    throw(SzMismatchError("TArray<T>::MultElt(const TArray<T>&) SizeMismatch")) ;
     288  nSide_= a.nSide_;
     289  nPix_ = a.nPix_;
     290  omeg_ = a.omeg_;
     291  int k;
     292  for (k=0; k< nPix_; k++) pixels_(k) = a.pixels_(k);
     293  for (k=0; k< a.sliceBeginIndex_.Size(); k++) sliceBeginIndex_(k) = a.sliceBeginIndex_(k);
     294  for (k=0; k< a.sliceLenght_.Size(); k++) sliceLenght_(k) = a.sliceLenght_(k);
     295  return(*this);
     296}
    270297//++
    271298// Titre        Destructor
Note: See TracChangeset for help on using the changeset viewer.