Debian Codegraph @

testing/projects/cpp_pimpl/src/earth.cpp

raw
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 #include <pimpl/earth.hpp>
14
15 namespace pimpl {
16 class EarthImpl {
17 public:
18 double mass = 5.97237e24;
19 double radius = 6'371.0;
20 double eccentricity = 0.0167086;
21 double surface_gravity = 9.807;
22 };
23
24 Earth::Earth() :
25 Planet()
26 , pimpl{std::make_unique<EarthImpl>()} { }
27
28 Earth::~Earth() = default;
29 Earth::Earth(Earth&&) = default;
30 Earth& Earth::operator=(Earth&&) = default;
31
32 double Earth::mass() const { return pimpl->mass; }
33 double Earth::radius() const { return pimpl->radius; }
34 double Earth::eccentricity() const { return pimpl->eccentricity; }
35 double Earth::surface_gravity() const { return pimpl->surface_gravity; }
36
37 namespace detail {
38 class EarthImpl {
39 public:
40 double mass = 5.97237e24;
41 double radius = 6'371.0;
42 double eccentricity = 0.0167086;
43 double surface_gravity = 9.807;
44 };
45 }
46
47 Earth_v2::Earth_v2() :
48 Planet()
49 , pimpl{std::make_unique<detail::EarthImpl>()} { }
50
51 Earth_v2::~Earth_v2() = default;
52 Earth_v2::Earth_v2(Earth_v2&&) = default;
53 Earth_v2& Earth_v2::operator=(Earth_v2&&) = default;
54
55 double Earth_v2::mass() const { return pimpl->mass; }
56 double Earth_v2::radius() const { return pimpl->radius; }
57 double Earth_v2::eccentricity() const { return pimpl->eccentricity; }
58 double Earth_v2::surface_gravity() const { return pimpl->surface_gravity; }
59 }