Something idk
This commit is contained in:
parent
c12682dd2a
commit
ef784580b4
@ -8,3 +8,4 @@ _Эталонная имплементация библиотеки с реал
|
||||
## Пространства имён
|
||||
|
||||
`Stadium::Base`: базовые инструменты, не подлежащие принципиальному изменению в будущем.
|
||||
`Stadium::v1`: то, что может быть изменено в последующих версиях.
|
@ -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 <typename CategoryT = uint8_t, typename SubcategoryT = uint8_t>
|
||||
|
||||
|
||||
namespace Stadium {
|
||||
namespace v1 {
|
||||
|
||||
template <typename CategoryT = uint8_t, typename SubcategoryT = uint8_t, typename PayloadT = KLDRArray<>> // 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;
|
||||
};
|
||||
|
||||
}
|
35
src/EventQueue.hpp
Normal file
35
src/EventQueue.hpp
Normal file
@ -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 <vector>
|
||||
#include "Event.hpp"
|
||||
|
||||
|
||||
|
||||
namespace Stadium {
|
||||
namespace Base {
|
||||
|
||||
template <typename EventT = Event<>> // TODO: переделать через рантайм-дрисню
|
||||
class EventQueue {
|
||||
protected:
|
||||
std::vector<EventT> Queue;
|
||||
|
||||
public:
|
||||
//void Add (EventT);
|
||||
//EventT Get ();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -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 {
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* utils.hpp
|
||||
* Utils.hpp
|
||||
* Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms.
|
||||
*
|
||||
*/
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* event.cpp
|
||||
* Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "event.hpp"
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <cstdio>
|
||||
#include "stadium.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "Stadium.hpp"
|
||||
#include "Utils.hpp"
|
||||
|
||||
|
||||
int main () {
|
||||
|
Loading…
Reference in New Issue
Block a user