source: Sophya/trunk/SophyaLib/Samba/spherepos.cc@ 745

Last change on this file since 745 was 701, checked in by ansari, 26 years ago

mise a jour de persistances par objets delegues

File size: 3.0 KB
RevLine 
[701]1// 04/01/00 : implantation de la persistance par classe deleguee - Guy Le Meur
2
[518]3#include "spherepos.h"
4
[701]5static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/Samba/spherepos.cc,v 1.4 2000-01-04 14:27:15 ansari Exp $";
[518]6
7
8//................. SphereCoordSys class .................
9
10SphereCoordSys::SphereCoordSys(){
11 id_ = SphereCoordSys_NEUTRAL;
12 description_ = "NEUTRAL SphereCoordSystem";
13}
[701]14SphereCoordSys::SphereCoordSys(const SphereCoordSys& a )
15{
16 id_ = a.id_;
17 description_ = a.description_;
18}
[518]19
20SphereCoordSys::SphereCoordSys(int id, const string& description){
21 id_ = id;
22 description_ = description;
23}
24
[525]25SphereCoordSys::~SphereCoordSys()
26{
27}
[701]28SphereCoordSys& SphereCoordSys::operator = (const SphereCoordSys& a)
29{
30 id_ = a.id_;
31 description_ = a.description_;
32 return *this;
33}
[525]34
[701]35
36////////////////////////////////////////////////////////////////
37// -------------------------------------------------------------------------
38// Les objets delegues pour la gestion de persistance
39// -------------------------------------------------------------------------
40
41FIO_SphereCoordSys::FIO_SphereCoordSys()
42 {
43 dobj=new SphereCoordSys;
44 ownobj=true;
45 }
46FIO_SphereCoordSys::FIO_SphereCoordSys(string const & filename)
47 {
48 dobj=new SphereCoordSys;
49 ownobj=true;
50 Read(filename);
51 }
52FIO_SphereCoordSys::FIO_SphereCoordSys(const SphereCoordSys & obj)
53 {
54 dobj = new SphereCoordSys(obj);
55 ownobj=true;
56 }
57FIO_SphereCoordSys::FIO_SphereCoordSys(SphereCoordSys * obj)
58 {
59 dobj = obj;
60 ownobj=false;
61 }
62FIO_SphereCoordSys::~FIO_SphereCoordSys()
63 {
64 if (ownobj && dobj) delete dobj;
65 }
66AnyDataObj* FIO_SphereCoordSys::DataObj()
67 {
68 return(dobj);
69 }
70
71
72void FIO_SphereCoordSys::ReadSelf(PInPersist& is)
73 {
[518]74uint_8 itab[3];
[701]75 string description;
[518]76is.Get(itab, 3);
[701]77is.GetStr(description);
78if (dobj == NULL) dobj = new SphereCoordSys(itab[1], description);
79 else *dobj= SphereCoordSys(itab[1], description);
80 }
81void FIO_SphereCoordSys::WriteSelf(POutPersist& os) const
[518]82{
[701]83if (dobj == NULL) return; // Attention - $CHECK$ Guy 04/01/00
[518]84// On ecrit 3 uint_8
85// 0 : Numero de version, 1 : Id, 2 reserve a l
86uint_8 itab[3];
87itab[0] = 1;
[701]88itab[1] = dobj->Id();
[518]89itab[2] = 0;
90os.Put(itab, 3);
[701]91os.PutStr(dobj->description());
92}
[518]93
[701]94
95
[518]96//................. SpherePosition class .................
97
98SpherePosition::SpherePosition()
99 : UnitVector()
100{
101 cs_ = new SphereCoordSys;
102}
103
104SpherePosition::SpherePosition(double theta, double phi, SphereCoordSys* cs)
105 : UnitVector(theta, phi)
106{
107if (cs == NULL) cs_ = new SphereCoordSys;
108else cs_ = cs;
109}
110
111SpherePosition::SpherePosition(double x, double y, double z, SphereCoordSys* cs)
112 : UnitVector(x, y, z)
113{
114if (cs == NULL) cs_ = new SphereCoordSys;
115else cs_ = cs;
116}
117
[525]118SpherePosition::~SpherePosition()
119{
120if (cs_) delete cs_;
121}
122
[682]123UnitVector SpherePosition::Transform(const SphereCoordSys& /*cs*/) const
[518]124{
125return(*this);
126}
127
128double SpherePosition::Separation(const SpherePosition& gamma) const
129{
130return(this->SepAngle(gamma));
131}
Note: See TracBrowser for help on using the repository browser.