17#ifndef _FGE_NETWORK_MANAGER_HPP_INCLUDED
18#define _FGE_NETWORK_MANAGER_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
21#include "FastEngine/C_scene.hpp"
22#include "FastEngine/network/C_client.hpp"
23#include "FastEngine/network/C_packet.hpp"
24#include "FastEngine/object/C_object.hpp"
109 [[nodiscard]]
constexpr TValue*
extract();
116 template<
class TPeek>
117 [[nodiscard]]
constexpr std::optional<TPeek>
peek();
120 [[nodiscard]]
constexpr TValue
const& value()
const;
121 [[nodiscard]]
constexpr TValue& value();
132 template<
class TInvokable>
133 [[nodiscard]]
constexpr typename std::invoke_result_t<TInvokable, ChainedArguments<TValue>&>
148 template<
class TInvokable,
class TIndex>
150 and_for_each(TIndex iStart, TIndex iEnd, TIndex iIncrement, TInvokable&& f);
165 template<
class TInvokable,
class TIndex>
178 template<
class TInvokable>
190 template<
class TInvokable>
191 constexpr std::optional<Error>
on_error(TInvokable&& f);
197 [[nodiscard]]
constexpr std::optional<Error>
end();
206 [[nodiscard]]
constexpr std::optional<Error>
end(std::nullopt_t nullopt)
const;
213 [[nodiscard]]
constexpr std::optional<Error>
end(
Error&& err)
const;
226 template<
class TInvokable>
245 template<
class TNewValue>
257 template<
class TNewValue>
276 using Value = std::variant<TValue, TValue*>;
288enum class ROutputs :
bool
306template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
307constexpr ChainedArguments<TValue>
RRange(TValue
const& min, TValue
const& max, ChainedArguments<TValue>&& args);
316template<
class TValue>
317constexpr ChainedArguments<TValue>
RValid(ChainedArguments<TValue>&& args);
328template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
329constexpr ChainedArguments<TValue>
RMustEqual(TValue
const& a, ChainedArguments<TValue>&& args);
340template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
341constexpr ChainedArguments<TValue>
RStrictLess(TValue less, ChainedArguments<TValue>&& args);
352template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
353constexpr ChainedArguments<TValue>
RLess(TValue less, ChainedArguments<TValue>&& args);
371template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
372constexpr ChainedArguments<TValue>
RSizeRange(SizeType min, SizeType max, ChainedArguments<TValue>&& args);
385template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
386constexpr ChainedArguments<TValue>
RSizeMustEqual(fge::net::SizeType a, ChainedArguments<TValue>&& args);
399template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
400constexpr ChainedArguments<TValue>
RMustValidUtf8(ChainedArguments<TValue>&& args);
409#include "network_manager.inl"
A scene contain a collection of object and handle them.
Definition C_scene.hpp:450
Definition C_packet.hpp:70
This is a wrapper around a Packet and a value for safe extraction.
Definition network_manager.hpp:92
constexpr ChainedArguments< TValue > & setError(Error &&err)
Set the error.
Definition network_manager.inl:263
constexpr std::optional< TPeek > peek()
Peek without changing the read position a copy of value.
Definition network_manager.inl:73
constexpr ChainedArguments< TNewValue > newChain(TNewValue *existingValue=nullptr)
Create a new chain with a different value type.
Definition network_manager.inl:251
constexpr ChainedArguments< TValue > & apply(TValue &value)
Apply the extracted value to the provided reference.
Definition network_manager.inl:219
constexpr TValue * extract()
Extract and verify the value from the packet.
Definition network_manager.inl:58
constexpr std::invoke_result_t< TInvokable, ChainedArguments< TValue > & > and_then(TInvokable &&f)
Chain up some code after a successful extraction.
Definition network_manager.inl:111
constexpr ChainedArguments< TValue > & and_for_each(TIndex iStart, TIndex iEnd, TIndex iIncrement, TInvokable &&f)
Chain up some code in a for loop after a successful extraction.
Definition network_manager.inl:122
constexpr std::optional< Error > on_error(TInvokable &&f)
Chain up some code after a unsuccessful extraction.
Definition network_manager.inl:193
constexpr std::optional< Error > end()
End the chain by doing a last validity check on the packet.
Definition network_manager.inl:203
constexpr ChainedArguments< TValue > & invalidate(Error &&err)
Invalidate the packet and set the error.
Definition network_manager.inl:269
constexpr ChainedArguments< TValue > RRange(TValue const &min, TValue const &max, ChainedArguments< TValue > &&args)
Range rule, check if the value is in the min/max range.
Definition network_manager.inl:277
constexpr ChainedArguments< TValue > RMustValidUtf8(ChainedArguments< TValue > &&args)
Check if the extracted string is a valid UTF8 string.
Definition network_manager.inl:393
constexpr ChainedArguments< TValue > RStrictLess(TValue less, ChainedArguments< TValue > &&args)
Strict less rule, check if the value is strictly lesser than the provided one.
Definition network_manager.inl:325
constexpr ChainedArguments< TValue > RMustEqual(TValue const &a, ChainedArguments< TValue > &&args)
Must equal rule, check if the value is equal to the provided one.
Definition network_manager.inl:308
constexpr ChainedArguments< TValue > RSizeMustEqual(fge::net::SizeType a, ChainedArguments< TValue > &&args)
Size must equal rule, check if the size is equal to the provided one.
Definition network_manager.inl:376
constexpr ChainedArguments< TValue > RSizeRange(SizeType min, SizeType max, ChainedArguments< TValue > &&args)
Size range rule, check if the size is in the min/max range.
Definition network_manager.inl:359
constexpr ChainedArguments< TValue > RValid(ChainedArguments< TValue > &&args)
Valid rule, check if the value is correctly extracted.
Definition network_manager.inl:294
constexpr ChainedArguments< TValue > RLess(TValue less, ChainedArguments< TValue > &&args)
Less rule, check if the value is lesser than the provided one.
Definition network_manager.inl:342
fge::net::Skey GetSkey(fge::net::Packet &pck)
Shortcut function that will extract the skey.
Definition network_manager.inl:29
bool CheckSkey(fge::net::Packet &pck, fge::net::Skey skey)
Shortcut function that will extract and compare the provided skey.
Definition network_manager.inl:20
FGE_API bool WritePacketDataToFile(fge::net::Packet &pck, std::string const &file)
Utility function to write packet data into a file.
FGE_API uint32_t GetSceneChecksum(fge::Scene &scene)
Get a basic scene checksum.
uint32_t Skey
The session key can be used to identify a client when connecting to a server.
Definition C_client.hpp:47
Definition C_packet.hpp:45