CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
NetworkClient.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
12
15
16#include <atomic>
17#include <cstdint>
18#include <iosfwd>
19
20namespace CeresEngine {
21
24 using RawT = UInt64;
25
28 UInt64 raw = 0;
29
32 inline constexpr NetworkClientID() noexcept = default;
33
37 constexpr NetworkClientID(const NetworkClientID& other) noexcept = default;
38
43 constexpr NetworkClientID& operator=(const NetworkClientID& other) noexcept = default;
44
48 explicit inline constexpr NetworkClientID(const UInt64 raw) noexcept : raw(raw) {}
49
50 public: // Operators
56 [[nodiscard]] friend inline constexpr bool operator==(const NetworkClientID& a, const NetworkClientID& b) noexcept { return a.raw == b.raw; }
57
63 [[nodiscard]] friend inline constexpr bool operator!=(const NetworkClientID& a, const NetworkClientID& b) noexcept { return a.raw != b.raw; }
64
69 [[nodiscard]] friend inline constexpr bool operator<(const NetworkClientID& a, const NetworkClientID& b) noexcept { return a.raw < b.raw; }
70
75 [[nodiscard]] friend inline constexpr bool operator<=(const NetworkClientID& a, const NetworkClientID& b) noexcept { return a.raw <= b.raw; }
76
81 [[nodiscard]] friend inline constexpr bool operator>(const NetworkClientID& a, const NetworkClientID& b) noexcept { return a.raw > b.raw; }
82
87 [[nodiscard]] friend inline constexpr bool operator>=(const NetworkClientID& a, const NetworkClientID& b) noexcept { return a.raw >= b.raw; }
88
93 friend std::ostream& operator<<(std::ostream& os, const NetworkClientID& clientID);
94 };
95
107
109
111 private:
114
115 public:
119 };
120
121} // namespace CeresEngine
#define CE_SCRIPT_EXPORT(...)
The CE_SCRIPT_EXPORT macro marks a class or method as exportable and available in scripting environme...
Definition Macros.hpp:247
#define CE_STRUCT_ENUM_DECL(T)
Definition StructEnum.hpp:49
Definition NetworkClient.hpp:108
Definition NetworkClient.hpp:110
NetworkClientID operator()() noexcept
Allocates a new client ID.
Definition NetworkClient.hpp:118
Atomic< decltype(NetworkClientID::raw)> nextID
The next raw ID to be allocated.
Definition NetworkClient.hpp:113
Definition StructEnum.hpp:18
UInt32 UnderlyingType
Definition StructEnum.hpp:20
Definition Application.hpp:19
std::uint64_t UInt64
Definition DataTypes.hpp:26
std::atomic< T > Atomic
The Atomic template defines an atomic type.
Definition Atomic.hpp:16
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition NetworkClient.hpp:22
friend constexpr bool operator<=(const NetworkClientID &a, const NetworkClientID &b) noexcept
Compares two client IDs for <=.
Definition NetworkClient.hpp:75
friend constexpr bool operator>(const NetworkClientID &a, const NetworkClientID &b) noexcept
Compares two client IDs for >.
Definition NetworkClient.hpp:81
friend constexpr bool operator>=(const NetworkClientID &a, const NetworkClientID &b) noexcept
Compares two client IDs for >=.
Definition NetworkClient.hpp:87
UInt64 RawT
The raw type.
Definition NetworkClient.hpp:24
friend std::ostream & operator<<(std::ostream &os, const NetworkClientID &clientID)
Prints a string representation of the Client ID.
UInt64 raw
The raw network client ID.
Definition NetworkClient.hpp:28
friend constexpr bool operator!=(const NetworkClientID &a, const NetworkClientID &b) noexcept
Compares two client IDs for inequality.
Definition NetworkClient.hpp:63
friend constexpr bool operator<(const NetworkClientID &a, const NetworkClientID &b) noexcept
Compares two client IDs for <.
Definition NetworkClient.hpp:69
friend constexpr bool operator==(const NetworkClientID &a, const NetworkClientID &b) noexcept
Compares two client IDs for equality.
Definition NetworkClient.hpp:56
An enumeration that represents the current state the network client is in.
Definition NetworkClient.hpp:97
enum CeresEngine::NetworkClientState::@31 raw
@ Connected
Definition NetworkClient.hpp:101
@ Disconnected
Definition NetworkClient.hpp:99
@ Connecting
Definition NetworkClient.hpp:100
@ Error
Definition NetworkClient.hpp:103
@ Disconnecting
Definition NetworkClient.hpp:102