sciplot  0.3.1
A modern C++ plotting library powered by gnuplot
DepthSpecsOf.hpp
1 // sciplot - a modern C++ scientific plotting library powered by gnuplot
2 // https://github.com/sciplot/sciplot
3 //
4 // Licensed under the MIT License <http://opensource.org/licenses/MIT>.
5 //
6 // Copyright (c) 2018-2021 Allan Leal
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 // sciplot includes
29 #include <sciplot/specs/Specs.hpp>
30 
31 namespace sciplot {
32 
34 template <typename DerivedSpecs>
35 class DepthSpecsOf : virtual public Specs<DerivedSpecs>
36 {
37  public:
40 
42  auto front() -> DerivedSpecs&;
43 
45  auto back() -> DerivedSpecs&;
46 
50  auto behind() -> DerivedSpecs&;
51 
53  auto repr() const -> std::string;
54 
55  private:
57  std::string m_depth;
58 };
59 
61 class DepthSpecs : public DepthSpecsOf<DepthSpecs> {};
62 
63 template <typename DerivedSpecs>
65 {
66  back();
67 }
68 
69 template <typename DerivedSpecs>
70 auto DepthSpecsOf<DerivedSpecs>::front() -> DerivedSpecs&
71 {
72  m_depth = "front";
73  return static_cast<DerivedSpecs&>(*this);
74 }
75 
76 template <typename DerivedSpecs>
77 auto DepthSpecsOf<DerivedSpecs>::back() -> DerivedSpecs&
78 {
79  m_depth = "back";
80  return static_cast<DerivedSpecs&>(*this);
81 }
82 
83 template <typename DerivedSpecs>
84 auto DepthSpecsOf<DerivedSpecs>::behind() -> DerivedSpecs&
85 {
86  m_depth = "behind";
87  return static_cast<DerivedSpecs&>(*this);
88 }
89 
90 template <typename DerivedSpecs>
91 auto DepthSpecsOf<DerivedSpecs>::repr() const -> std::string
92 {
93  return m_depth;
94 }
95 
96 } // namespace sciplot
The class used to specify depth options.
Definition: DepthSpecsOf.hpp:61
DepthSpecsOf()
Construct a default DepthSpecsOf instance.
Definition: DepthSpecsOf.hpp:64
auto behind() -> DerivedSpecs &
Set the underlying plot element to be displayed behind of all plot elements.
Definition: DepthSpecsOf.hpp:84
The class used to attach depth options to a type.
Definition: DepthSpecsOf.hpp:36
auto front() -> DerivedSpecs &
Set the underlying plot element to be displayed on the front of all plot elements.
Definition: DepthSpecsOf.hpp:70
The base class for other specs classes (e.g., LineSpecsOf, DrawSpecs, BorderSpecs,...
Definition: Specs.hpp:36
auto back() -> DerivedSpecs &
Set the underlying plot element to be displayed on the back of all plot elements.
Definition: DepthSpecsOf.hpp:77
auto repr() const -> std::string
Convert this DepthSpecsOf object into a gnuplot formatted string.
Definition: DepthSpecsOf.hpp:91