forked from Green-Sky/tomato
comp refactor and make groups work
This commit is contained in:
parent
7ac62274f4
commit
d21dbb43e2
@ -11,12 +11,15 @@ add_library(fragment_store
|
|||||||
./fragment_store/fragment_store.cpp
|
./fragment_store/fragment_store.cpp
|
||||||
|
|
||||||
./json/message_components.hpp # TODO: move
|
./json/message_components.hpp # TODO: move
|
||||||
|
./json/tox_message_components.hpp # TODO: move
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(fragment_store PUBLIC
|
target_link_libraries(fragment_store PUBLIC
|
||||||
nlohmann_json::nlohmann_json
|
nlohmann_json::nlohmann_json
|
||||||
EnTT::EnTT
|
EnTT::EnTT
|
||||||
solanaceae_util
|
solanaceae_util
|
||||||
|
|
||||||
|
solanaceae_tox_messages # TODO: move
|
||||||
)
|
)
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
@ -26,6 +29,11 @@ add_library(message_fragment_store
|
|||||||
./fragment_store/message_serializer.cpp
|
./fragment_store/message_serializer.cpp
|
||||||
./fragment_store/message_fragment_store.hpp
|
./fragment_store/message_fragment_store.hpp
|
||||||
./fragment_store/message_fragment_store.cpp
|
./fragment_store/message_fragment_store.cpp
|
||||||
|
|
||||||
|
./fragment_store/register_mfs_json_message_components.hpp
|
||||||
|
./fragment_store/register_mfs_json_message_components.cpp
|
||||||
|
./fragment_store/register_mfs_json_tox_message_components.hpp
|
||||||
|
./fragment_store/register_mfs_json_tox_message_components.cpp
|
||||||
)
|
)
|
||||||
target_compile_features(message_fragment_store PRIVATE cxx_std_20)
|
target_compile_features(message_fragment_store PRIVATE cxx_std_20)
|
||||||
target_link_libraries(message_fragment_store PUBLIC
|
target_link_libraries(message_fragment_store PUBLIC
|
||||||
|
@ -305,7 +305,7 @@ bool FragmentStore::syncToStorage(FragmentID fid, std::function<write_to_storage
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "storage type: type_id:" << type_id << " name:" << storage.type().name() << "\n";
|
//std::cout << "storage type: type_id:" << type_id << " name:" << storage.type().name() << "\n";
|
||||||
|
|
||||||
// use type_id to find serializer
|
// use type_id to find serializer
|
||||||
auto s_cb_it = _sc._serl_json.find(type_id);
|
auto s_cb_it = _sc._serl_json.find(type_id);
|
||||||
|
@ -209,7 +209,7 @@ void MessageFragmentStore::loadFragment(Message3Registry& reg, FragmentHandle fh
|
|||||||
auto new_real_msg = Message3Handle{reg, reg.create()};
|
auto new_real_msg = Message3Handle{reg, reg.create()};
|
||||||
// load into staging reg
|
// load into staging reg
|
||||||
for (const auto& [k, v] : j_entry.items()) {
|
for (const auto& [k, v] : j_entry.items()) {
|
||||||
std::cout << "K:" << k << " V:" << v.dump() << "\n";
|
//std::cout << "K:" << k << " V:" << v.dump() << "\n";
|
||||||
const auto type_id = entt::hashed_string(k.data(), k.size());
|
const auto type_id = entt::hashed_string(k.data(), k.size());
|
||||||
const auto deserl_fn_it = _sc._deserl_json.find(type_id);
|
const auto deserl_fn_it = _sc._deserl_json.find(type_id);
|
||||||
if (deserl_fn_it != _sc._deserl_json.cend()) {
|
if (deserl_fn_it != _sc._deserl_json.cend()) {
|
||||||
@ -238,6 +238,10 @@ void MessageFragmentStore::loadFragment(Message3Registry& reg, FragmentHandle fh
|
|||||||
// walking EVERY existing message OOF
|
// walking EVERY existing message OOF
|
||||||
// this needs optimizing
|
// this needs optimizing
|
||||||
for (const Message3 other_msg : reg.view<Message::Components::Timestamp, Message::Components::ContactFrom, Message::Components::ContactTo>()) {
|
for (const Message3 other_msg : reg.view<Message::Components::Timestamp, Message::Components::ContactFrom, Message::Components::ContactTo>()) {
|
||||||
|
if (other_msg == new_real_msg) {
|
||||||
|
continue; // skip self
|
||||||
|
}
|
||||||
|
|
||||||
if (comp({reg, other_msg}, new_real_msg)) {
|
if (comp({reg, other_msg}, new_real_msg)) {
|
||||||
// dup
|
// dup
|
||||||
dup_msg = other_msg;
|
dup_msg = other_msg;
|
||||||
@ -281,34 +285,6 @@ MessageFragmentStore::MessageFragmentStore(
|
|||||||
_fs._sc.registerSerializerJson<FragComp::MessagesContact>();
|
_fs._sc.registerSerializerJson<FragComp::MessagesContact>();
|
||||||
_fs._sc.registerDeSerializerJson<FragComp::MessagesContact>();
|
_fs._sc.registerDeSerializerJson<FragComp::MessagesContact>();
|
||||||
|
|
||||||
_sc.registerSerializerJson<Message::Components::Timestamp>();
|
|
||||||
_sc.registerDeSerializerJson<Message::Components::Timestamp>();
|
|
||||||
_sc.registerSerializerJson<Message::Components::TimestampProcessed>();
|
|
||||||
_sc.registerDeSerializerJson<Message::Components::TimestampProcessed>();
|
|
||||||
_sc.registerSerializerJson<Message::Components::TimestampWritten>();
|
|
||||||
_sc.registerDeSerializerJson<Message::Components::TimestampWritten>();
|
|
||||||
_sc.registerSerializerJson<Message::Components::ContactFrom>();
|
|
||||||
_sc.registerDeSerializerJson<Message::Components::ContactFrom>();
|
|
||||||
_sc.registerSerializerJson<Message::Components::ContactTo>();
|
|
||||||
_sc.registerDeSerializerJson<Message::Components::ContactTo>();
|
|
||||||
_sc.registerSerializerJson<Message::Components::TagUnread>();
|
|
||||||
_sc.registerDeSerializerJson<Message::Components::TagUnread>();
|
|
||||||
_sc.registerSerializerJson<Message::Components::Read>();
|
|
||||||
_sc.registerDeSerializerJson<Message::Components::Read>();
|
|
||||||
_sc.registerSerializerJson<Message::Components::MessageText>();
|
|
||||||
_sc.registerDeSerializerJson<Message::Components::MessageText>();
|
|
||||||
_sc.registerSerializerJson<Message::Components::TagMessageIsAction>();
|
|
||||||
_sc.registerDeSerializerJson<Message::Components::TagMessageIsAction>();
|
|
||||||
|
|
||||||
// files
|
|
||||||
//_sc.registerSerializerJson<Message::Components::Transfer::FileID>()
|
|
||||||
//_sc.registerSerializerJson<Message::Components::Transfer::FileInfo>();
|
|
||||||
//_sc.registerDeSerializerJson<Message::Components::Transfer::FileInfo>();
|
|
||||||
//_sc.registerSerializerJson<Message::Components::Transfer::FileInfoLocal>();
|
|
||||||
//_sc.registerDeSerializerJson<Message::Components::Transfer::FileInfoLocal>();
|
|
||||||
//_sc.registerSerializerJson<Message::Components::Transfer::TagHaveAll>();
|
|
||||||
//_sc.registerDeSerializerJson<Message::Components::Transfer::TagHaveAll>();
|
|
||||||
|
|
||||||
_fs.subscribe(this, FragmentStore_Event::fragment_construct);
|
_fs.subscribe(this, FragmentStore_Event::fragment_construct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,6 +292,10 @@ MessageFragmentStore::~MessageFragmentStore(void) {
|
|||||||
// TODO: sync all dirty fragments
|
// TODO: sync all dirty fragments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageSerializerCallbacks& MessageFragmentStore::getMSC(void) {
|
||||||
|
return _sc;
|
||||||
|
}
|
||||||
|
|
||||||
float MessageFragmentStore::tick(float time_delta) {
|
float MessageFragmentStore::tick(float time_delta) {
|
||||||
// sync dirty fragments here
|
// sync dirty fragments here
|
||||||
|
|
||||||
@ -351,13 +331,13 @@ float MessageFragmentStore::tick(float time_delta) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "storage type: type_id:" << type_id << " name:" << storage.type().name() << "\n";
|
//std::cout << "storage type: type_id:" << type_id << " name:" << storage.type().name() << "\n";
|
||||||
|
|
||||||
// use type_id to find serializer
|
// use type_id to find serializer
|
||||||
auto s_cb_it = _sc._serl_json.find(type_id);
|
auto s_cb_it = _sc._serl_json.find(type_id);
|
||||||
if (s_cb_it == _sc._serl_json.end()) {
|
if (s_cb_it == _sc._serl_json.end()) {
|
||||||
// could not find serializer, not saving
|
// could not find serializer, not saving
|
||||||
std::cout << "missing " << storage.type().name() << "\n";
|
std::cout << "missing " << storage.type().name() << "(" << type_id << ")\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +71,8 @@ class MessageFragmentStore : public RegistryMessageModelEventI, public FragmentS
|
|||||||
);
|
);
|
||||||
virtual ~MessageFragmentStore(void);
|
virtual ~MessageFragmentStore(void);
|
||||||
|
|
||||||
|
MessageSerializerCallbacks& getMSC(void);
|
||||||
|
|
||||||
float tick(float time_delta);
|
float tick(float time_delta);
|
||||||
|
|
||||||
void triggerScan(void);
|
void triggerScan(void);
|
||||||
|
35
src/fragment_store/register_mfs_json_message_components.cpp
Normal file
35
src/fragment_store/register_mfs_json_message_components.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include "./register_mfs_json_message_components.hpp"
|
||||||
|
|
||||||
|
#include "./message_serializer.hpp"
|
||||||
|
#include "../json/message_components.hpp"
|
||||||
|
|
||||||
|
void registerMFSJsonMessageComponents(MessageSerializerCallbacks& msc) {
|
||||||
|
msc.registerSerializerJson<Message::Components::Timestamp>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::Timestamp>();
|
||||||
|
msc.registerSerializerJson<Message::Components::TimestampProcessed>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::TimestampProcessed>();
|
||||||
|
msc.registerSerializerJson<Message::Components::TimestampWritten>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::TimestampWritten>();
|
||||||
|
msc.registerSerializerJson<Message::Components::ContactFrom>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::ContactFrom>();
|
||||||
|
msc.registerSerializerJson<Message::Components::ContactTo>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::ContactTo>();
|
||||||
|
msc.registerSerializerJson<Message::Components::TagUnread>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::TagUnread>();
|
||||||
|
msc.registerSerializerJson<Message::Components::Read>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::Read>();
|
||||||
|
msc.registerSerializerJson<Message::Components::MessageText>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::MessageText>();
|
||||||
|
msc.registerSerializerJson<Message::Components::TagMessageIsAction>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::TagMessageIsAction>();
|
||||||
|
|
||||||
|
// files
|
||||||
|
//_sc.registerSerializerJson<Message::Components::Transfer::FileID>()
|
||||||
|
//_sc.registerSerializerJson<Message::Components::Transfer::FileInfo>();
|
||||||
|
//_sc.registerDeSerializerJson<Message::Components::Transfer::FileInfo>();
|
||||||
|
//_sc.registerSerializerJson<Message::Components::Transfer::FileInfoLocal>();
|
||||||
|
//_sc.registerDeSerializerJson<Message::Components::Transfer::FileInfoLocal>();
|
||||||
|
//_sc.registerSerializerJson<Message::Components::Transfer::TagHaveAll>();
|
||||||
|
//_sc.registerDeSerializerJson<Message::Components::Transfer::TagHaveAll>();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "./message_serializer.hpp"
|
||||||
|
|
||||||
|
void registerMFSJsonMessageComponents(MessageSerializerCallbacks& msc);
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
#include "./register_mfs_json_message_components.hpp"
|
||||||
|
|
||||||
|
#include "./message_serializer.hpp"
|
||||||
|
#include "../json/tox_message_components.hpp"
|
||||||
|
|
||||||
|
void registerMFSJsonToxMessageComponents(MessageSerializerCallbacks& msc) {
|
||||||
|
msc.registerSerializerJson<Message::Components::ToxGroupMessageID>();
|
||||||
|
msc.registerDeSerializerJson<Message::Components::ToxGroupMessageID>();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "./message_serializer.hpp"
|
||||||
|
|
||||||
|
void registerMFSJsonToxMessageComponents(MessageSerializerCallbacks& msc);
|
||||||
|
|
16
src/json/tox_message_components.hpp
Normal file
16
src/json/tox_message_components.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <solanaceae/util/utils.hpp>
|
||||||
|
|
||||||
|
#include <solanaceae/tox_messages/components.hpp>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
namespace Message::Components {
|
||||||
|
|
||||||
|
// TODO: friend msg id, does not have the same qualities
|
||||||
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ToxGroupMessageID, id)
|
||||||
|
// TODO: transfer stuff, needs content rewrite
|
||||||
|
|
||||||
|
} // Message::Components
|
||||||
|
|
@ -1,5 +1,7 @@
|
|||||||
#include "./main_screen.hpp"
|
#include "./main_screen.hpp"
|
||||||
#include "fragment_store/fragment_store.hpp"
|
|
||||||
|
#include "./fragment_store/register_mfs_json_message_components.hpp"
|
||||||
|
#include "./fragment_store/register_mfs_json_tox_message_components.hpp"
|
||||||
|
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
|
|
||||||
@ -35,6 +37,8 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path, std::stri
|
|||||||
tdch(tpi)
|
tdch(tpi)
|
||||||
{
|
{
|
||||||
tel.subscribeAll(tc);
|
tel.subscribeAll(tc);
|
||||||
|
registerMFSJsonMessageComponents(mfs.getMSC());
|
||||||
|
registerMFSJsonToxMessageComponents(mfs.getMSC());
|
||||||
|
|
||||||
conf.set("tox", "save_file_path", save_path);
|
conf.set("tox", "save_file_path", save_path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user