bactria  0.0.1
The bactria library is a header-only C++14 library for profiling and tracing.
Marker.hpp
Go to the documentation of this file.
1 /* Copyright 2021 Jan Stephan
2  *
3  * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
4  * the European Commission - subsequent versions of the EUPL (the “Licence”).
5  * You may not use this work except in compliance with the Licence.
6  * You may obtain a copy of the Licence at:
7  *
8  * http://ec.europa.eu/idabc/eupl.html
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the Licence is distributed on an “AS IS” basis, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * Licence permissions and limitations under the Licence.
14  */
15 
24 #pragma once
25 
28 
29 #include <cstdint>
30 #include <string>
31 #include <utility>
32 
33 namespace bactria
34 {
35  namespace ranges
36  {
50  class Marker
51  {
52  public:
59  Marker() = default;
60 
70  Marker(std::string name, std::uint32_t color, Category category)
71  : m_name{std::move(name)}
72  , m_color{color}
73  , m_category{std::move(category)}
74  {
75  }
76 
85  Marker(Marker const& other) = default;
86 
95  auto operator=(Marker const& rhs) -> Marker& = default;
96 
105  Marker(Marker&& other) = default;
106 
115  auto operator=(Marker&& rhs) -> Marker& = default;
116 
120  virtual ~Marker() = default;
121 
129  auto get_name() const noexcept -> std::string const&
130  {
131  return m_name;
132  }
133 
141  auto get_c_name() const noexcept -> char const*
142  {
143  return m_name.c_str();
144  }
145 
153  auto get_color() const noexcept -> std::uint32_t
154  {
155  return m_color;
156  }
157 
165  auto get_category() const noexcept -> Category const&
166  {
167  return m_category;
168  }
169 
170  protected:
177  std::string m_name{"BACTRIA_GENERIC_MARKER"};
178 
185  std::uint32_t m_color{color::orange};
186 
194  };
195 
199  } // namespace ranges
200 } // namespace bactria
bactria::ranges::color::orange
constexpr auto orange
Definition: Colors.hpp:997
bactria::ranges::Marker::Marker
Marker(std::string name, std::uint32_t color, Category category)
Constructor.
Definition: Marker.hpp:70
bactria::ranges::Marker::get_category
auto get_category() const noexcept -> Category const &
Return the marker's category.
Definition: Marker.hpp:165
bactria::ranges::Marker::m_name
std::string m_name
The name assigned to the Marker.
Definition: Marker.hpp:177
Colors.hpp
Color definitions.
bactria::ranges::Marker
The abstract base class for markers.
Definition: Marker.hpp:50
bactria::ranges::Marker::m_color
std::uint32_t m_color
The color assigned to the Marker.
Definition: Marker.hpp:185
Category.hpp
Category definitions.
bactria::ranges::Marker::get_c_name
auto get_c_name() const noexcept -> char const *
Return the marker's name (C string).
Definition: Marker.hpp:141
bactria::ranges::Category
Defines a category.
Definition: Category.hpp:39
bactria::ranges::Marker::get_color
auto get_color() const noexcept -> std::uint32_t
Return the marker's color.
Definition: Marker.hpp:153
bactria::ranges::Marker::m_category
Category m_category
The Category assigned to the Marker.
Definition: Marker.hpp:193
bactria::ranges::Marker::~Marker
virtual ~Marker()=default
Destroy the Marker object.
bactria::ranges::Marker::operator=
auto operator=(Marker const &rhs) -> Marker &=default
Copy-assignment operator.
bactria::ranges::Marker::Marker
Marker()=default
Default constructor.
bactria::ranges::Marker::get_name
auto get_name() const noexcept -> std::string const &
Return the marker's name.
Definition: Marker.hpp:129