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