// 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