UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
base_buffer.hpp
1
42#ifndef UFO_UTILITY_BASE_BUFFER_HPP
43#define UFO_UTILITY_BASE_BUFFER_HPP
44
45// UFO
46#include <ufo/utility/io/dir.hpp>
47
48// STL
49#include <cstddef>
50#include <cstdint>
51
52namespace ufo
53{
55{
56 public:
57 using size_type = std::size_t;
58 using pos_type = std::uintmax_t;
59 using offset_type = std::intmax_t;
60
61 [[nodiscard]] constexpr std::byte const* data() const noexcept { return data_; }
62
63 [[nodiscard]] constexpr bool empty() const noexcept { return 0 == size_; }
64
65 [[nodiscard]] constexpr size_type size() const noexcept { return size_; }
66
67 protected:
68 constexpr BaseBuffer() = default;
69
70 constexpr BaseBuffer(std::byte const* data, size_type size) : data_(data), size_(size)
71 {
72 }
73
74 [[nodiscard]] constexpr pos_type pos(pos_type pos, offset_type off,
75 IODir dir) const noexcept
76 {
77 switch (dir) {
78 case IODir::Beg: return off;
79 case IODir::End: return size_ + off;
80 case IODir::Cur: return pos + off;
81 }
82
83 return 0;
84 }
85
86 protected:
87 std::byte const* data_ = nullptr;
88 size_type size_{};
89};
90} // namespace ufo
91#endif // UFO_UTILITY_BASE_BUFFER_HPP
All vision-related classes and functions.
Definition cloud.hpp:49