// G. Le Meur 04/2000 #include "fiospherehealpix.h" #include "pexceptions.h" #include "fiondblock.h" //******************************************************************* // Class FIO_SphereHealpix // Les objets delegues pour la gestion de persistance //******************************************************************* template FIO_SphereHealpix::FIO_SphereHealpix() { dobj_= new SphereHealpix; ownobj= true; } template FIO_SphereHealpix::FIO_SphereHealpix(string const& filename) { dobj_= new SphereHealpix; dobj_->SetTemp(true); ownobj= true; Read(filename); } template FIO_SphereHealpix::FIO_SphereHealpix(const SphereHealpix& obj) { dobj_= new SphereHealpix(obj, true); dobj_->SetTemp(true); ownobj= true; } template FIO_SphereHealpix::FIO_SphereHealpix(SphereHealpix* obj) { dobj_= obj; ownobj= false; } template FIO_SphereHealpix::~FIO_SphereHealpix() { if (ownobj && dobj_) delete dobj_; } template AnyDataObj* FIO_SphereHealpix::DataObj() { return(dobj_); } template void FIO_SphereHealpix::SetDataObj(AnyDataObj & o) { SphereHealpix * po = dynamic_cast< SphereHealpix * >(&o); if (po == NULL) return; if (ownobj && dobj_) delete dobj_; dobj_ = po; ownobj = false; } template void FIO_SphereHealpix::ReadSelf(PInPersist& is) { if(dobj_ == NULL) { dobj_= new SphereHealpix; dobj_->SetTemp(true); ownobj= true; } // On lit les 3 premiers uint_8 uint_8 itab[3]; is.Get(itab, 3); // Let's Read the SphereCoordSys object -- ATTENTIOn - $CHECK$ FIO_SphereCoordSys fio_scs( dobj_->GetCoordSys()); fio_scs.Read(is); // Pour savoir s'il y avait un DVList Infodobj->Info(); associe char strg[256]; is.GetLine(strg, 255); bool hadinfo= false; if(strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo= true; if(hadinfo) { // Lecture eventuelle du DVList Info is >> dobj_->Info(); } int_4 nSide; is.GetI4(nSide); int_4 nPix; is.GetI4(nPix); double Omega; is.GetR8(Omega); dobj_->setParameters(nSide,nPix, Omega); // On lit les DataBlocks; FIO_NDataBlock fio_nd(&dobj_->pixels_); fio_nd.Read(is); FIO_NDataBlock fio_ndi1(&dobj_->sliceBeginIndex_); fio_ndi1.Read(is); FIO_NDataBlock fio_ndi2(&dobj_->sliceLenght_); fio_ndi2.Read(is); } template void FIO_SphereHealpix::WriteSelf(POutPersist& os) const { if(dobj_ == NULL) { cout << " WriteSelf:: dobj_= null " << endl; return; } // On ecrit 3 uint_8 // 0 : Numero de version, 1 : Size index, 2 reserve a l uint_8 itab[3]; itab[0] = 1; itab[1] = dobj_->SizeIndex(); itab[2] = 0; os.Put(itab, 3); // Let's write the SphereCoordSys object FIO_SphereCoordSys fio_scs( dobj_->GetCoordSys()); fio_scs.Write(os); char strg[256]; int_4 nSide= dobj_->SizeIndex(); int_4 nPix = dobj_->NbPixels(); if(dobj_->ptrInfo()) { sprintf(strg,"SphereHealpix: NSide=%6d NPix=%9d HasInfo",nSide,nPix); os.PutLine(strg); os << dobj_->Info(); } else { sprintf(strg,"SphereHealpix: NSide=%6d NPix=%9d ",nSide,nPix); os.PutLine(strg); } os.PutI4(nSide); os.PutI4(nPix); os.PutR8(dobj_->PixSolAngle()); // On ecrit les dataBlocks FIO_NDataBlock fio_nd(&dobj_->pixels_); fio_nd.Write(os); FIO_NDataBlock fio_ndi1(&dobj_->sliceBeginIndex_); fio_ndi1.Write(os); FIO_NDataBlock fio_ndi2(&dobj_->sliceLenght_); fio_ndi2.Write(os); } //******************************************************************* #ifdef __CXX_PRAGMA_TEMPLATES__ #pragma define_template FIO_SphereHealpix #pragma define_template FIO_SphereHealpix #pragma define_template FIO_SphereHealpix< complex > #pragma define_template FIO_SphereHealpix< complex > #endif #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) template class FIO_SphereHealpix; template class FIO_SphereHealpix; template class FIO_SphereHealpix< complex >; template class FIO_SphereHealpix< complex >; #endif