| 1 |
/*************************************************************************************** |
| 2 |
* This file is dedicated to the public domain. It is a minor modification of the * |
| 3 |
* simple yet effective PIMPL article here: * |
| 4 |
* * |
| 5 |
* https://cpppatterns.com/patterns/pimpl.html * |
| 6 |
* * |
| 7 |
* If your jurisdiction requires a specific license: * |
| 8 |
* * |
| 9 |
* Copyright (c) Joseph Mansfield, Mehdi Amini, 2017 * |
| 10 |
* License: CC0 1.0 Universal * |
| 11 |
* License Text: https://creativecommons.org/publicdomain/zero/1.0/legalcode * |
| 12 |
**************************************************************************************/ |
| 13 |
#pragma once |
| 14 |
|
| 15 |
#include <pimpl/planet.hpp> |
| 16 |
#include <memory> |
| 17 |
|
| 18 |
namespace pimpl { |
| 19 |
/** |
| 20 |
* \class pimpl::JupiterImpl jupiter.hpp include/pimpl/jupiter.hpp |
| 21 |
* \brief The Jupiter PIMPL. |
| 22 |
*/ |
| 23 |
class JupiterImpl; |
| 24 |
|
| 25 |
/// A class that represents the planet Jupiter. |
| 26 |
class Jupiter : public Planet { |
| 27 |
public: |
| 28 |
Jupiter(); ///< Constructs an Jupiter. |
| 29 |
~Jupiter(); ///< Destructs an Jupiter. |
| 30 |
Jupiter(Jupiter&&); ///< Moves an Jupiter. |
| 31 |
Jupiter& operator=(Jupiter&&);///< Assigns an Jupiter. |
| 32 |
|
| 33 |
/// The mass of the Jupiter in kilograms. |
| 34 |
double mass() const; |
| 35 |
/// The mean radius of the Jupiter in kilometers. |
| 36 |
double radius() const; |
| 37 |
/// The orbital eccentricity of the Jupiter. |
| 38 |
double eccentricity() const; |
| 39 |
/// The gravity on the Jupiter surface in meters per second squared. |
| 40 |
double surface_gravity() const; |
| 41 |
/// A string description of the planet. |
| 42 |
std::string describe() const { return "Jupiter"; } |
| 43 |
|
| 44 |
protected: |
| 45 |
/// The Jupiter implementation details. |
| 46 |
std::unique_ptr<JupiterImpl> pimpl; |
| 47 |
}; |
| 48 |
|
| 49 |
namespace detail { |
| 50 |
/** |
| 51 |
* \class pimpl::detail::JupiterImpl jupiter.hpp include/pimpl/jupiter.hpp |
| 52 |
* \brief The Jupiter_v2 PIMPL. |
| 53 |
*/ |
| 54 |
class JupiterImpl; |
| 55 |
} |
| 56 |
|
| 57 |
/// A class that represents the planet Jupiter (version 2). |
| 58 |
class Jupiter_v2 : public Planet { |
| 59 |
public: |
| 60 |
Jupiter_v2(); ///< Constructs an Jupiter_v2. |
| 61 |
~Jupiter_v2(); ///< Destructs an Jupiter_v2. |
| 62 |
Jupiter_v2(Jupiter_v2&&); ///< Moves an Jupiter_v2. |
| 63 |
Jupiter_v2& operator=(Jupiter_v2&&);///< Assigns an Jupiter_v2. |
| 64 |
|
| 65 |
/// The mass of the Jupiter_v2 in kilograms. |
| 66 |
double mass() const; |
| 67 |
/// The mean radius of the Jupiter_v2 in kilometers. |
| 68 |
double radius() const; |
| 69 |
/// The orbital eccentricity of the Jupiter_v2. |
| 70 |
double eccentricity() const; |
| 71 |
/// The gravity on the Jupiter_v2 surface in meters per second squared. |
| 72 |
double surface_gravity() const; |
| 73 |
/// A string description of the planet. |
| 74 |
std::string describe() const { return "Jupiter_v2"; } |
| 75 |
|
| 76 |
protected: |
| 77 |
/// The Jupiter_v2 implementation details. |
| 78 |
std::unique_ptr<detail::JupiterImpl> pimpl; |
| 79 |
}; |
| 80 |
} |