source: Sophya/trunk/SophyaLib/SkyMap/fiosphereecp.cc@ 3818

Last change on this file since 3818 was 2882, checked in by ansari, 20 years ago

Pb instanciation explicite ds namespace (compil magique) - Reza 3/01/2006

File size: 3.8 KB
RevLine 
[2610]1// G. Le Meur 04/2000
2
[2615]3#include "sopnamsp.h"
[2610]4#include "fiosphereecp.h"
5#include "fioarr.h"
6#include "pexceptions.h"
7#include "datatype.h"
8#include <typeinfo>
9
10///////////////////////////////////////////////////////////
11// --------------------------------------------------------
12// Les classes delegues pour la gestion de persistance
13// --------------------------------------------------------
14//////////////////////////////////////////////////////////
15namespace SOPHYA {
16
17template <class T>
18FIO_SphereECP<T>::FIO_SphereECP()
19{
20 dobj= new SphereECP<T>;
21 ownobj= true;
22}
23
24template <class T>
25FIO_SphereECP<T>::FIO_SphereECP(string const& filename)
26{
27 dobj= new SphereECP<T>;
28 ownobj= true;
29 Read(filename);
30}
31
32template <class T>
33FIO_SphereECP<T>::FIO_SphereECP(const SphereECP<T>& obj)
34{
35 dobj= new SphereECP<T>(obj, true);
36 ownobj= true;
37}
38
39template <class T>
40FIO_SphereECP<T>::FIO_SphereECP(SphereECP<T>* obj)
41{
42 dobj= obj;
43 ownobj= false;
44}
45
46template <class T>
47FIO_SphereECP<T>::~FIO_SphereECP()
48{
49 if (ownobj && dobj) delete dobj;
50}
51
52template <class T>
53AnyDataObj* FIO_SphereECP<T>::DataObj()
54{
55 return(dobj);
56}
57
58
59template <class T>
60void FIO_SphereECP<T>::SetDataObj(AnyDataObj & o)
61{
62 SphereECP<T> * po = dynamic_cast< SphereECP<T> * >(&o);
63 if (po == NULL) {
64 char buff[160];
65 sprintf(buff,"FIO_SphereECP<%s>::SetDataObj(%s) - Object type error ! ",
66 DataTypeInfo<T>::getTypeName().c_str(), typeid(o).name());
67 throw TypeMismatchExc(PExcLongMessage(buff));
68 }
69
70 if (ownobj && dobj) delete dobj;
71 dobj = po; ownobj = false;
72}
73
74template <class T>
75void FIO_SphereECP<T>::ReadSelf(PInPersist& is)
76{
77 if(dobj == NULL) {
78 dobj= new SphereECP<T>;
79 ownobj= true;
80 }
81
82 // On lit les 3 premiers uint_8
83 int_4 itab[4];
84 is.Get(itab, 4);
85 dobj->_partial = (itab[1] & 1) ? true : false;
86
87 is >> dobj->_theta1 >> dobj->_theta2 ;
88 is >> dobj->_phi1 >> dobj->_phi2;
89 is >> dobj->_dtheta >> dobj->_dphi;
90 is >> dobj->_outofmapidx >> dobj->_outofmappix >> dobj->_outofmapval;
91 // Let's Read the SphereCoordSys object -- ATTENTIOn - $CHECK$
92 FIO_SphereCoordSys fio_scs( dobj->GetCoordSys());
93 fio_scs.Read(is);
94 // S'il y avait un objet Info() a lire
95 if (itab[1] & 2) is >> dobj->Info();
96 // On lit le tableau des pixels
97 is >> dobj->_pixels;
98}
99
100template <class T>
101void FIO_SphereECP<T>::WriteSelf(POutPersist& os) const
102{
103 if(dobj == NULL) {
104 cout << " FIO_SphereECP<T>::WriteSelf:: dobj= null " << endl;
105 return;
106 }
107// On ecrit 4 int_4
108// itab[0] : Numero de version,
109//itab[1] = 0 full map, , =1 partial map (bit 0) , bit 1 set -> has info
110// itab[2], itab[3] reserve a un usage futur
111 int_4 itab[4];
112 itab[0] = 1;
113 itab[1] = (dobj->IsPartial()) ? 1 : 0;
114 if (dobj->ptrInfo() != NULL) itab[1] |=
115 itab[2] = itab[3] = 0;
116 os.Put(itab, 4);
117
118 os << dobj->_theta1 << dobj->_theta2 ;
119 os << dobj->_phi1 << dobj->_phi2;
120 os << dobj->_dtheta << dobj->_dphi;
121 os << dobj->_outofmapidx << dobj->_outofmappix << dobj->_outofmapval;
122
123 // Let's write the SphereCoordSys object
124 FIO_SphereCoordSys fio_scs( dobj->GetCoordSys());
125 fio_scs.Write(os);
126 // On ecrit l'objet info si necessaire
127 if (dobj->ptrInfo() != NULL) os << dobj->Info();
128
129 // On ecrit le tableau des pixels
130 os << dobj->_pixels;
131}
132
[2882]133}// Fin du namespace
134
[2610]135#ifdef __CXX_PRAGMA_TEMPLATES__
136#pragma define_template FIO_SphereECP<int_4>
137#pragma define_template FIO_SphereECP<r_8>
138#pragma define_template FIO_SphereECP<r_4>
139#pragma define_template FIO_SphereECP< complex<r_4> >
140#pragma define_template FIO_SphereECP< complex<r_8> >
141#endif
142#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
[2869]143namespace SOPHYA {
[2610]144template class FIO_SphereECP<int_4>;
145template class FIO_SphereECP<r_8>;
146template class FIO_SphereECP<r_4>;
147template class FIO_SphereECP< complex<r_4> >;
148template class FIO_SphereECP< complex<r_8> >;
[2869]149}
[2610]150#endif
151
Note: See TracBrowser for help on using the repository browser.