1
0
Fork 0

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.
This commit is contained in:
Edward d'Auvergne 2017-05-29 13:35:56 +02:00
parent a0dc7b5ba3
commit d2a6eb69a5
2 changed files with 11 additions and 11 deletions

View file

@ -26,7 +26,6 @@
#include <simgear/ephemeris/ephemeris.hxx> #include <simgear/ephemeris/ephemeris.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/fg_props.hxx>
static void tieStar(const char* prop, Star* s, double (Star::*getter)() const) 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<MoonPos, double>(*s, getter, NULL)); fgGetNode(prop, true)->tie(SGRawValueMethods<MoonPos, double>(*s, getter, NULL));
} }
Ephemeris::Ephemeris() : Ephemeris::Ephemeris()
_impl(NULL),
_latProp(NULL)
{ {
} }
@ -50,14 +47,14 @@ Ephemeris::~Ephemeris()
SGEphemeris* Ephemeris::data() SGEphemeris* Ephemeris::data()
{ {
return _impl; return _impl.get();
} }
void Ephemeris::init() void Ephemeris::init()
{ {
SGPath ephem_data_path(globals->get_fg_root()); SGPath ephem_data_path(globals->get_fg_root());
ephem_data_path.append("Astro"); 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/xs", _impl->get_sun(), &Star::getxs);
tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys); tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
@ -82,8 +79,7 @@ void Ephemeris::init()
void Ephemeris::shutdown() void Ephemeris::shutdown()
{ {
delete _impl; _impl.reset();
_impl = NULL;
} }
void Ephemeris::postinit() void Ephemeris::postinit()
@ -97,6 +93,8 @@ void Ephemeris::bind()
void Ephemeris::unbind() void Ephemeris::unbind()
{ {
_latProp = 0; _latProp = 0;
_latProp.reset();
_moonlight.reset();
} }
void Ephemeris::update(double) void Ephemeris::update(double)

View file

@ -25,6 +25,8 @@
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
#include <Main/fg_props.hxx>
class SGEphemeris; class SGEphemeris;
class SGPropertyNode; class SGPropertyNode;
@ -49,9 +51,9 @@ public:
SGEphemeris* data(); SGEphemeris* data();
private: private:
SGEphemeris* _impl; std::unique_ptr<SGEphemeris> _impl;
SGPropertyNode* _latProp; SGPropertyNode_ptr _latProp;
SGPropertyNode* _moonlight; SGPropertyNode_ptr _moonlight;
}; };
#endif // of FG_ENVIRONMENT_EPHEMERIS_HXX #endif // of FG_ENVIRONMENT_EPHEMERIS_HXX