source: Sophya/trunk/SophyaLib/SkyMap/fiospherethetaphi.cc@ 4018

Last change on this file since 4018 was 2869, checked in by ansari, 20 years ago

Portage/compilation sur AIX-XlC (regatta): Ajout qualification de nom ou namespace SOPHYA pour instanciation explicite de template - Reza 3 Jan 2006

File size: 4.9 KB
RevLine 
[842]1// G. Le Meur 04/2000
2
[2615]3#include "sopnamsp.h"
[842]4#include "fiospherethetaphi.h"
5#include "pexceptions.h"
6#include "fiondblock.h"
[1967]7#include "datatype.h"
8#include <typeinfo>
[842]9
10///////////////////////////////////////////////////////////
11// --------------------------------------------------------
12// Les objets delegues pour la gestion de persistance
13// --------------------------------------------------------
14//////////////////////////////////////////////////////////
15
16template <class T>
17FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi()
18{
19 dobj= new SphereThetaPhi<T>;
20 ownobj= true;
21}
22
23template <class T>
24FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(string const& filename)
25{
26 dobj= new SphereThetaPhi<T>;
27 ownobj= true;
28 Read(filename);
29}
30
31template <class T>
32FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(const SphereThetaPhi<T>& obj)
33{
34 dobj= new SphereThetaPhi<T>(obj, true);
35 ownobj= true;
36}
37
38template <class T>
39FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(SphereThetaPhi<T>* obj)
40{
41 dobj= obj;
42 ownobj= false;
43}
44
45template <class T>
46FIO_SphereThetaPhi<T>::~FIO_SphereThetaPhi()
47{
48 if (ownobj && dobj) delete dobj;
49}
50
51template <class T>
52AnyDataObj* FIO_SphereThetaPhi<T>::DataObj()
53{
54 return(dobj);
55}
56
57
58template <class T>
59void FIO_SphereThetaPhi<T>::SetDataObj(AnyDataObj & o)
60{
61 SphereThetaPhi<T> * po = dynamic_cast< SphereThetaPhi<T> * >(&o);
[1967]62 if (po == NULL) {
63 char buff[160];
64 sprintf(buff,"FIO_SphereThetaPhi<%s>::SetDataObj(%s) - Object type error ! ",
65 DataTypeInfo<T>::getTypeName().c_str(), typeid(o).name());
66 throw TypeMismatchExc(PExcLongMessage(buff));
67 }
68
[842]69 if (ownobj && dobj) delete dobj;
70 dobj = po; ownobj = false;
71}
72
73template <class T>
74void FIO_SphereThetaPhi<T>::ReadSelf(PInPersist& is)
75{
76
77 if(dobj == NULL)
78 {
79 dobj= new SphereThetaPhi<T>;
80 ownobj= true;
81 }
82
83 // On lit les 3 premiers uint_8
84 uint_8 itab[3];
85 is.Get(itab, 3);
86// Let's Read the SphereCoordSys object -- ATTENTIOn - $CHECK$
87 FIO_SphereCoordSys fio_scs( dobj->GetCoordSys());
88 fio_scs.Read(is);
89
90 // Pour savoir s'il y avait un DVList Info associe
91 char strg[256];
92 is.GetLine(strg, 255);
93 bool hadinfo= false;
94 if(strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo= true;
95 if(hadinfo)
96 { // Lecture eventuelle du DVList Info
97 is >> dobj->Info();
98 }
99
100 int_4 mNTheta;
101 is.GetI4(mNTheta);
102 int_4 mNPix;
103 is.GetI4(mNPix);
104 double mOmeg;
105 is.GetR8(mOmeg);
106 dobj->setParameters( mNTheta, mNPix, mOmeg);
[1145]107
[1163]108 // FIO_NDataBlock<int_4> fio_nd_nphi( &dobj->NPhi_);
109 // fio_nd_nphi.Read(is);
110 // FIO_NDataBlock<int_4> fio_nd_Tnphi(&dobj->TNphi_);
111 // fio_nd_Tnphi.Read(is);
112 // FIO_NDataBlock<r_8> fio_nd_Theta( &dobj->Theta_);
113 // fio_nd_Theta.Read(is);
114 // FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
115 // fio_nd.Read(is);
[842]116
[1163]117 // Reza 30/8/2000 , - Methode de lecture plus facile
118
119 is >> dobj->NPhi_ ;
120 is >> dobj->TNphi_ ;
121 is >> dobj->Theta_;
122 is >> dobj->pixels_;
[842]123}
124
125template <class T>
126void FIO_SphereThetaPhi<T>::WriteSelf(POutPersist& os) const
127{
128
129 if(dobj == NULL)
130 {
131 cout << " WriteSelf:: dobj= null " << endl;
132 return;
133 }
134
135// On ecrit 3 uint_8
136// 0 : Numero de version, 1 : Size index, 2 reserve a l
137uint_8 itab[3];
138itab[0] = 1;
139itab[1] = dobj->SizeIndex();
140itab[2] = 0;
141os.Put(itab, 3);
142// Let's write the SphereCoordSys object
143 FIO_SphereCoordSys fio_scs( dobj->GetCoordSys());
144 fio_scs.Write(os);
145
146 char strg[256];
147 int_4 mNTheta= dobj->SizeIndex();
148 int_4 mNPix = dobj->NbPixels();
149
150 if(dobj->ptrInfo())
151 {
152 sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d HasInfo",mNTheta,mNPix);
153 os.PutLine(strg);
154 os << dobj->Info();
155 }
156 else
157 {
158 sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d ",mNTheta,mNPix);
159 os.PutLine(strg);
160 }
161
162 os.PutI4(mNTheta);
163 os.PutI4(mNPix);
164 os.PutR8(dobj->PixSolAngle());
[1145]165
[1163]166 // FIO_NDataBlock<int_4> fio_nd_nphi(&dobj->NPhi_);
167 // fio_nd_nphi.Write(os);
168 // FIO_NDataBlock<int_4> fio_nd_Tnphi(&dobj->TNphi_);
169 // fio_nd_Tnphi.Write(os);
170 // FIO_NDataBlock<r_8> fio_nd_Theta(&dobj->Theta_);
171 // fio_nd_Theta.Write(os);
172 // FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
173 // fio_nd.Write(os);
174
175 // Reza 30/8/2000 , - Methode d'ecriture plus facile
176
177 os << dobj->NPhi_;
178 os << dobj->TNphi_;
179 os << dobj->Theta_;
180 os << dobj->pixels_;
[842]181}
182
183#ifdef __CXX_PRAGMA_TEMPLATES__
[2083]184#pragma define_template FIO_SphereThetaPhi<int_4>
[842]185#pragma define_template FIO_SphereThetaPhi<r_8>
186#pragma define_template FIO_SphereThetaPhi<r_4>
187#pragma define_template FIO_SphereThetaPhi< complex<r_4> >
188#pragma define_template FIO_SphereThetaPhi< complex<r_8> >
189#endif
190#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
[2869]191namespace SOPHYA {
[2083]192template class FIO_SphereThetaPhi<int_4>;
[842]193template class FIO_SphereThetaPhi<r_8>;
194template class FIO_SphereThetaPhi<r_4>;
195template class FIO_SphereThetaPhi< complex<r_4> >;
196template class FIO_SphereThetaPhi< complex<r_8> >;
[2869]197}
[842]198#endif
Note: See TracBrowser for help on using the repository browser.