CppEphem
CEBody.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * CEBody.cpp: CppEphem *
3  * ----------------------------------------------------------------------- *
4  * Copyright © 2016-2019 JCardenzana *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 
28 #include <stdio.h>
29 
30 #include "CEBody.h"
31 
32 /**********************************************************************/
36 {
37  init_members();
38 }
39 
40 /**********************************************************************/
49 CEBody::CEBody(const std::string& name,
50  const CEAngle& xcoord,
51  const CEAngle& ycoord,
52  const CESkyCoordType& coord_type) :
53  CESkyCoord(xcoord, ycoord, coord_type)
54 {
55  init_members();
56  SetName(name);
57 }
58 
59 /**********************************************************************/
64 CEBody::CEBody(const CEBody& other,
65  const std::string& name) :
66  CESkyCoord(other)
67 {
68  init_members();
69  copy_members(other);
70 
71  // Set the name if it is not empty
72  if (name.size() > 0) SetName(name);
73 }
74 
75 /**********************************************************************/
79 CEBody::CEBody(const CESkyCoord& coords,
80  const std::string& name) :
81  CESkyCoord(coords)
82 {
83  init_members();
84 
85  // Set the name if it is not empty
86  if (name.size() > 0) SetName(name);
87 }
88 
89 /**********************************************************************/
93 {
94  free_members();
95 }
96 
97 
98 /*--------------------------------------------------*
99  * Overloaded operators
100  *--------------------------------------------------*/
101 
102 
103 /**********************************************************************/
108 CEBody& CEBody::operator=(const CEBody& other)
109 {
110  if (this != &other) {
111  // Copy parent class parameters
112  this->CESkyCoord::operator=(other);
113 
114  // Reset this object and copy values from 'other'
115  free_members();
116  init_members();
117  copy_members(other);
118  }
119  return *this;
120 }
121 
122 /*--------------------------------------------------*
123  * Public methods
124  *--------------------------------------------------*/
125 
126 
127 /**********************************************************************/
131  const CEObserver& observer) const
132 {
133  CESkyCoord coords_icrs = GetCoordinates(date);
134  return coords_icrs.ConvertToObserved(date, observer);
135 }
136 
137 
138 /*--------------------------------------------------*
139  * Private methods
140  *--------------------------------------------------*/
141 
142 
143 /**********************************************************************/
146 void CEBody::free_members(void)
147 {
148 }
149 
150 
151 /**********************************************************************/
154 void CEBody::init_members(void)
155 {
156  name_ = "undefined";
157 }
158 
159 
160 /**********************************************************************/
163 void CEBody::copy_members(const CEBody& other)
164 {
165  name_ = other.name_;
166 }
CESkyCoordType
CESkyCoordType
The following enum specifies what coordinates this object represents.
Definition: CESkyCoord.h:39
CEDate
Definition: CEDate.h:43
CEBody::~CEBody
virtual ~CEBody()
Destructor.
Definition: CEBody.cpp:91
CESkyCoord
Definition: CESkyCoord.h:49
CEBody::init_members
void init_members(void)
Initialize data members.
Definition: CEBody.cpp:153
CEBody::GetCoordinates
virtual CESkyCoord GetCoordinates(const CEDate &date=CEDate::CurrentJD()) const
Return the ICRS coordinates associated with this object.
Definition: CEBody.h:121
CEBody::operator=
CEBody & operator=(const CEBody &other)
Overloaded assignment operator.
Definition: CEBody.cpp:107
CEBody::free_members
void free_members(void)
Free all allocated data members.
Definition: CEBody.cpp:145
CEBody::CEBody
CEBody()
Default constructor.
Definition: CEBody.cpp:34
CESkyCoord::operator=
CESkyCoord & operator=(const CESkyCoord &other)
Overloaded '=' (assignment) operator.
Definition: CESkyCoord.cpp:99
CEAngle
Definition: CEAngle.h:38
CEBody::copy_members
void copy_members(const CEBody &other)
Copy all data members.
Definition: CEBody.cpp:162
CEBody::ObservedCoords
virtual CESkyCoord ObservedCoords(const CEDate &date, const CEObserver &observer) const
Computes the observed coordinates for this object based.
Definition: CEBody.cpp:129
CESkyCoord::ConvertToObserved
CESkyCoord ConvertToObserved(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to OBSERVED coordinates.
Definition: CESkyCoord.cpp:928
CEObserver
Definition: CEObserver.h:28
CEBody.h
CEBody
Definition: CEBody.h:39
CEBody::name_
std::string name_
Name of this object.
Definition: CEBody.h:98