diff --git a/Src/Server/RemoteClient.hpp b/Src/Server/RemoteClient.hpp index f102b6d..f44a83b 100644 --- a/Src/Server/RemoteClient.hpp +++ b/Src/Server/RemoteClient.hpp @@ -1,16 +1,113 @@ #pragma once +#include #include #include #include "Abstract.hpp" #include #include #include +#include #include #include namespace LV::Server { +/* + Введение в распознавание образов + Распознавание символов + +*/ + + +template && std::is_integral_v && sizeof(ServerKey) >= sizeof(ClientKey), int> = 0> +class CSChunkedMapper { + std::unordered_map, std::array>> Chunks; + +public: + ServerKey remap(ClientKey cKey) { + int chunkIndex = cKey >> 6; + int subIndex = cKey & 0x3f; + + auto iChunk = Chunks.find(chunkIndex); + if(iChunk == Chunks.end()) + MAKE_ERROR("Идентификатор не привязан"); + + std::bitset<64> &bits = std::get<0>(iChunk.second); + std::array &keys = std::get<1>(iChunk.second); + + if(!bits.test(subIndex)) + MAKE_ERROR("Идентификатор не привязан"); + + return keys[subIndex]; + } + + void erase(ClientKey cKey) { + int chunkIndex = cKey >> 6; + int subIndex = cKey & 0x3f; + + auto iChunk = Chunks.find(chunkIndex); + if(iChunk == Chunks.end()) + MAKE_ERROR("Идентификатор не привязан"); + + std::bitset<64> &bits = std::get<0>(iChunk.second); + std::array &keys = std::get<1>(iChunk.second); + + if(!bits.test(subIndex)) + MAKE_ERROR("Идентификатор не привязан"); + + bits.reset(subIndex); + } + + void map(ClientKey cKey, ServerKey sKey) { + int chunkIndex = cKey >> 6; + int subIndex = cKey & 0x3f; + + std::tuple, std::array> &chunk = Chunks[chunkIndex]; + std::bitset<64> &bits = std::get<0>(chunk); + std::array &keys = std::get<1>(chunk); + + if(bits.test(subIndex)) { + MAKE_ERROR("Идентификатор уже занят"); + } + + bits.set(subIndex); + keys[subIndex] = sKey; + } +}; + +template +class SortedChunkedMap { + +struct Chunk { + uint8_t bitset = 0; + std::array, sizeof(bitset)> Data; +}; + +public: + +}; + +template && std::is_integral_v && sizeof(ServerKey) >= sizeof(ClientKey), int> = 0> +class SCMapper { + + +public: + +}; + +template && std::is_integral_v, int> = 0> +class SCKeyRemapper { + std::bitset<(1 << sizeof(ClientKey)*8) - 1> UsedIdC; // 1 - идентификатор свободен, 0 - занят + std::map SCTable; + +public: + // Если аллоцировать идентификатор не получится, будет возвращено ClientKey(0) + ClientKey toClient(ServerKey sKey) { + + }; +}; + /* Шаблоны игрового контента, которые необходимо поддерживать в актуальном состоянии для клиента и шаблоны, которые клиенту уже не нужны.