| 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 |
/** \file */ |
| 14 |
#pragma once |
| 15 |
|
| 16 |
#include <pimpl/planet.hpp> |
| 17 |
#include <memory> |
| 18 |
|
| 19 |
namespace pimpl { |
| 20 |
/** |
| 21 |
* \class pimpl::EarthImpl earth.hpp include/pimpl/earth.hpp |
| 22 |
* \brief The Earth PIMPL. |
| 23 |
*/ |
| 24 |
class EarthImpl; |
| 25 |
|
| 26 |
/// A class that represents the planet Earth. |
| 27 |
class Earth : public Planet { |
| 28 |
public: |
| 29 |
Earth(); ///< Constructs an Earth. |
| 30 |
~Earth(); ///< Destructs an Earth. |
| 31 |
Earth(Earth&&); ///< Moves an Earth. |
| 32 |
Earth& operator=(Earth&&);///< Assigns an Earth. |
| 33 |
|
| 34 |
/// The mass of the Earth in kilograms. |
| 35 |
double mass() const; |
| 36 |
/// The mean radius of the Earth in kilometers. |
| 37 |
double radius() const; |
| 38 |
/// The orbital eccentricity of the Earth. |
| 39 |
double eccentricity() const; |
| 40 |
/// The gravity on the Earth surface in meters per second squared. |
| 41 |
double surface_gravity() const; |
| 42 |
/// A string description of the planet. |
| 43 |
std::string describe() const { return "Earth"; } |
| 44 |
|
| 45 |
protected: |
| 46 |
/// The Earth implementation details. |
| 47 |
std::unique_ptr<EarthImpl> pimpl; |
| 48 |
}; |
| 49 |
|
| 50 |
/// The ``detail`` namespace contains items that should not be relied on in the public API. |
| 51 |
namespace detail { |
| 52 |
/** |
| 53 |
* \class pimpl::detail::EarthImpl earth.hpp include/pimpl/earth.hpp |
| 54 |
* \brief The Earth_v2 PIMPL. |
| 55 |
*/ |
| 56 |
class EarthImpl; |
| 57 |
} |
| 58 |
|
| 59 |
/// A class that represents the planet Earth_v2. |
| 60 |
class Earth_v2 : public Planet { |
| 61 |
public: |
| 62 |
Earth_v2(); ///< Constructs an Earth_v2. |
| 63 |
~Earth_v2(); ///< Destructs an Earth_v2. |
| 64 |
Earth_v2(Earth_v2&&); ///< Moves an Earth_v2. |
| 65 |
Earth_v2& operator=(Earth_v2&&);///< Assigns an Earth_v2. |
| 66 |
|
| 67 |
/// The mass of the Earth_v2 in kilograms. |
| 68 |
double mass() const; |
| 69 |
/// The mean radius of the Earth_v2 in kilometers. |
| 70 |
double radius() const; |
| 71 |
/// The orbital eccentricity of the Earth_v2. |
| 72 |
double eccentricity() const; |
| 73 |
/// The gravity on the Earth_v2 surface in meters per second squared. |
| 74 |
double surface_gravity() const; |
| 75 |
/// A string description of the planet. |
| 76 |
std::string describe() const { return "Earth_v2"; } |
| 77 |
|
| 78 |
protected: |
| 79 |
/// The Earth_v2 implementation details. |
| 80 |
std::unique_ptr<detail::EarthImpl> pimpl; |
| 81 |
}; |
| 82 |
} |