From d2a6eb69a5fe337b706fec86eaaf5adb7f0e9562 Mon Sep 17 00:00:00 2001 From: Edward d'Auvergne Date: Mon, 29 May 2017 13:35:56 +0200 Subject: [PATCH] Clean up of the Ephemeris class members, removing the raw pointers. The property nodes have been switched to SGPropertyNode_ptr and _impl to std::unique_ptr. --- src/Environment/ephemeris.cxx | 14 ++++++-------- src/Environment/ephemeris.hxx | 8 +++++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Environment/ephemeris.cxx b/src/Environment/ephemeris.cxx index cd17fae6d..8b6a75399 100644 --- a/src/Environment/ephemeris.cxx +++ b/src/Environment/ephemeris.cxx @@ -26,7 +26,6 @@ #include #include
-#include
static void tieStar(const char* prop, Star* s, double (Star::*getter)() const) { @@ -38,9 +37,7 @@ static void tieMoonPos(const char* prop, MoonPos* s, double (MoonPos::*getter)() fgGetNode(prop, true)->tie(SGRawValueMethods(*s, getter, NULL)); } -Ephemeris::Ephemeris() : - _impl(NULL), - _latProp(NULL) +Ephemeris::Ephemeris() { } @@ -50,14 +47,14 @@ Ephemeris::~Ephemeris() SGEphemeris* Ephemeris::data() { - return _impl; + return _impl.get(); } void Ephemeris::init() { SGPath ephem_data_path(globals->get_fg_root()); ephem_data_path.append("Astro"); - _impl = new SGEphemeris(ephem_data_path.local8BitStr()); + _impl.reset(new SGEphemeris(ephem_data_path.local8BitStr())); tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs); tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys); @@ -82,8 +79,7 @@ void Ephemeris::init() void Ephemeris::shutdown() { - delete _impl; - _impl = NULL; + _impl.reset(); } void Ephemeris::postinit() @@ -97,6 +93,8 @@ void Ephemeris::bind() void Ephemeris::unbind() { _latProp = 0; + _latProp.reset(); + _moonlight.reset(); } void Ephemeris::update(double) diff --git a/src/Environment/ephemeris.hxx b/src/Environment/ephemeris.hxx index 698b3165c..8250b7a8c 100644 --- a/src/Environment/ephemeris.hxx +++ b/src/Environment/ephemeris.hxx @@ -25,6 +25,8 @@ #include +#include
+ class SGEphemeris; class SGPropertyNode; @@ -49,9 +51,9 @@ public: SGEphemeris* data(); private: - SGEphemeris* _impl; - SGPropertyNode* _latProp; - SGPropertyNode* _moonlight; + std::unique_ptr _impl; + SGPropertyNode_ptr _latProp; + SGPropertyNode_ptr _moonlight; }; #endif // of FG_ENVIRONMENT_EPHEMERIS_HXX