diff --git a/README.md b/README.md index 57d866b..048712e 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,5 @@ _Эталонная имплементация библиотеки с реал ## Пространства имён -`Stadium::Base`: базовые инструменты, не подлежащие принципиальному изменению в будущем. \ No newline at end of file +`Stadium::Base`: базовые инструменты, не подлежащие принципиальному изменению в будущем. +`Stadium::v1`: то, что может быть изменено в последующих версиях. \ No newline at end of file diff --git a/src/event.hpp b/src/Event.hpp similarity index 54% rename from src/event.hpp rename to src/Event.hpp index c60e808..ad48b49 100644 --- a/src/event.hpp +++ b/src/Event.hpp @@ -1,5 +1,5 @@ /* - * event.hpp + * Event.hpp * Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms. * */ @@ -9,11 +9,18 @@ -namespace Stadium { -namespace Base { +#include "KLDR.hpp" -template + + +namespace Stadium { +namespace v1 { + +template > // TODO: переделать через рантайм-дрисню class Event { + // TODO: add static assertion of PayloadT (???) + // P.S.: https://stackoverflow.com/questions/874298/c-templates-that-accept-only-certain-types + public: struct { CategoryT Category; @@ -21,7 +28,7 @@ class Event { } Type; // ??? uint32_t ServerSession; // TODO: payload hash - // TODO: payload + PayloadT Payload; }; } diff --git a/src/EventQueue.hpp b/src/EventQueue.hpp new file mode 100644 index 0000000..672dfe3 --- /dev/null +++ b/src/EventQueue.hpp @@ -0,0 +1,35 @@ +/* + * EventQueue.hpp + * Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms. + * + */ + +#ifndef LIBSTADIUM_EVENTQUEUE_HPP +#define LIBSTADIUM_EVENTQUEUE_HPP + + + +#include +#include "Event.hpp" + + + +namespace Stadium { +namespace Base { + +template > // TODO: переделать через рантайм-дрисню +class EventQueue { + protected: + std::vector Queue; + + public: + //void Add (EventT); + //EventT Get (); +}; + +} +} + + + +#endif \ No newline at end of file diff --git a/src/kldr.hpp b/src/KLDR.hpp similarity index 97% rename from src/kldr.hpp rename to src/KLDR.hpp index 2dd0242..304dc8e 100644 --- a/src/kldr.hpp +++ b/src/KLDR.hpp @@ -1,5 +1,5 @@ /* - * kldr.hpp + * KLDR.hpp * Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms. * */ @@ -18,7 +18,8 @@ namespace Stadium { -namespace Base { + +namespace v1 { enum KLDRDefaultKeys : uint8_t { Data = 0x01, @@ -35,6 +36,10 @@ enum KLDRDefaultKeys : uint8_t { SignedDataHash = 0x13 }; +} + +namespace Base { + /* * KLDR stands for "Key-Length-Data-Repeat" * Schematically, binary array with KLDR-formatted data looks like this. @@ -183,7 +188,7 @@ class KLDRArray { this->AddF(key, length, data); } - // Get just value from array by key + // Get just pointer to value from array by key void* Get (KeyT key) { for (size_t i = 0; i < this->CellsAmount(); i++) { if (this->Keys[i] == key) { @@ -193,7 +198,7 @@ class KLDRArray { throw std::invalid_argument("invalid KLDRArray key"); } - // Get value and length from array by key + // Get pointer to value and length from array by key void* Get (KeyT key, LengthT* length) { for (size_t i = 0; i < this->CellsAmount(); i++) { if (this->Keys[i] == key) { @@ -236,6 +241,7 @@ class KLDRArray { }; } + } diff --git a/src/stadium.cpp b/src/Stadium.cpp similarity index 95% rename from src/stadium.cpp rename to src/Stadium.cpp index 2d5c16e..7c7efd1 100644 --- a/src/stadium.cpp +++ b/src/Stadium.cpp @@ -1,5 +1,5 @@ /* - * stadium.cpp + * Stadium.cpp * Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms. * * -> [ Incoming Events Queue ] --> [ Base Event Handlers ] @@ -11,7 +11,7 @@ * <- [ Custom Methods ] */ -#include "stadium.hpp" +#include "Stadium.hpp" diff --git a/src/stadium.hpp b/src/Stadium.hpp similarity index 59% rename from src/stadium.hpp rename to src/Stadium.hpp index 28ab551..45dcf93 100644 --- a/src/stadium.hpp +++ b/src/Stadium.hpp @@ -1,5 +1,5 @@ /* - * stadium.hpp + * Stadium.hpp * Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms. * */ @@ -9,18 +9,14 @@ -#include "kldr.hpp" +#include "EventQueue.hpp" namespace Stadium { namespace v1 { -// class EventsQueue { -// public: -// void Add (); // TODO -// void Pop (); // TODO -// }; +// TODO } } diff --git a/src/utils.hpp b/src/Utils.hpp similarity index 97% rename from src/utils.hpp rename to src/Utils.hpp index 8fb2001..bdd5cfe 100644 --- a/src/utils.hpp +++ b/src/Utils.hpp @@ -1,5 +1,5 @@ /* - * utils.hpp + * Utils.hpp * Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms. * */ diff --git a/src/event.cpp b/src/event.cpp deleted file mode 100644 index 40e71ea..0000000 --- a/src/event.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* - * event.cpp - * Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms. - * - */ - -#include "event.hpp" - - - diff --git a/src/test.cpp b/src/test.cpp index ae0c4c6..a480be8 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -1,6 +1,6 @@ #include -#include "stadium.hpp" -#include "utils.hpp" +#include "Stadium.hpp" +#include "Utils.hpp" int main () {