Specs change - so implementation change

This commit is contained in:
Shr3dd3r 2023-09-06 06:11:26 +03:00
parent ef784580b4
commit c84c62400b
4 changed files with 8 additions and 18 deletions

View File

@ -16,19 +16,15 @@
namespace Stadium { namespace Stadium {
namespace v1 { namespace v1 {
template <typename CategoryT = uint8_t, typename SubcategoryT = uint8_t, typename PayloadT = KLDRArray<>> // TODO: переделать через рантайм-дрисню
class Event { class Event {
// TODO: add static assertion of PayloadT (???)
// P.S.: https://stackoverflow.com/questions/874298/c-templates-that-accept-only-certain-types
public: public:
struct { struct {
CategoryT Category; uint8_t Category;
SubcategoryT Subcategory; uint8_t Subcategory;
} Type; // ??? } Type; // ???
uint32_t ServerSession; uint32_t ServerSession;
// TODO: payload hash // TODO: payload hash
PayloadT Payload; Base::KLDRArray<> Payload;
}; };
} }

View File

@ -15,16 +15,15 @@
namespace Stadium { namespace Stadium {
namespace Base { namespace v1 {
template <typename EventT = Event<>> // TODO: переделать через рантайм-дрисню
class EventQueue { class EventQueue {
protected: protected:
std::vector<EventT> Queue; std::vector<Event> Array;
public: public:
//void Add (EventT); //void Add (Event);
//EventT Get (); //Event Get ();
}; };
} }

View File

@ -44,7 +44,7 @@ namespace Base {
* KLDR stands for "Key-Length-Data-Repeat" * KLDR stands for "Key-Length-Data-Repeat"
* Schematically, binary array with KLDR-formatted data looks like this. * Schematically, binary array with KLDR-formatted data looks like this.
* Single cell: * Single cell:
* [key: 1/2 bytes][length of data: 1/2/4 bytes][data: length of data bytes] * [key: 1/2 bytes][length of data: 1/2/4 bytes][data: <length of data> bytes]
* Whole array: * Whole array:
* [cell 1][cell 2]...[cell n] * [cell 1][cell 2]...[cell n]
* *

View File

@ -15,14 +15,9 @@ int main () {
arr.Add(0xF4, sizeof(str3), (void*)&str3); arr.Add(0xF4, sizeof(str3), (void*)&str3);
arr.Add(0x6a, sizeof(str4), (void*)&str4); arr.Add(0x6a, sizeof(str4), (void*)&str4);
arr.Add(Stadium::Base::KLDRDefaultKeys::SignedDataHash, sizeof(str5), (void*)&str5); arr.Add(Stadium::Base::KLDRDefaultKeys::SignedDataHash, sizeof(str5), (void*)&str5);
arr.Print();
std::cout << "Shuffling!" << std::endl; std::cout << "Shuffling!" << std::endl;
arr.Shuffle(); arr.Shuffle();
arr.Print(); arr.Print();
size_t arr_sz = arr.FlatSize();
std::cout << "Calculated flat binary array size: " << arr_sz << std::endl;
std::cout << "Its contents:" << std::endl;
Stadium::Utils::PrintArray(arr.AsArray());
return 0; return 0;
} }