Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
Uuid.h
Go to the documentation of this file.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
23#pragma once
24
25#include <cstdint>
26
27namespace sese {
28
30class Uuid {
31public:
32 Uuid() noexcept = default;
37 Uuid(uint8_t self_id, uint64_t timestamp, uint8_t r = 0) noexcept;
38
41 [[nodiscard]] uint8_t getSelfId() const noexcept;
44 void setSelfId(uint8_t i) noexcept;
47 [[nodiscard]] uint8_t getR() const noexcept;
50 void setR(uint8_t r) noexcept;
53 [[nodiscard]] uint64_t getTimestamp() const noexcept;
56 void setTimestamp(uint64_t i) noexcept;
57
60 [[nodiscard]] uint64_t toNumber() const noexcept;
63 void parse(uint64_t number) noexcept;
64
65protected:
66 uint8_t selfId = 0;
67 uint8_t r = 0;
68 uint64_t timestamp = 0;
69};
70
71} // namespace sese