more comps

This commit is contained in:
Green Sky 2024-02-14 17:38:51 +01:00
parent 84987216cb
commit aa7a5d6013
No known key found for this signature in database
2 changed files with 36 additions and 19 deletions

View File

@ -12,8 +12,8 @@
namespace Message::Components { namespace Message::Components {
// ctx // ctx
struct OpenFragments { struct OpenFragments {
struct OpenFrag final { struct OpenFrag final {
uint64_t ts_begin {0}; uint64_t ts_begin {0};
uint64_t ts_end {0}; uint64_t ts_end {0};
@ -22,13 +22,21 @@ struct OpenFragments {
// only contains fragments with <1024 messages and <28h tsrage // only contains fragments with <1024 messages and <28h tsrage
// TODO: this needs to move into the message reg // TODO: this needs to move into the message reg
std::vector<OpenFrag> fuid_open; std::vector<OpenFrag> fuid_open;
}; };
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Timestamp, ts) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Timestamp, ts)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ContactFrom, c) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TimestampProcessed, ts)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ContactTo, c) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TimestampWritten, ts)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MessageText, text) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ContactFrom, c)
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TagMessageIsAction, void) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ContactTo, c)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Read, ts)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MessageText, text)
namespace Transfer {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FileInfo::FileDirEntry, file_name, file_size)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FileInfo, file_list, total_size)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FileInfoLocal, file_list)
} // Transfer
} // Message::Components } // Message::Components
@ -179,16 +187,20 @@ MessageFragmentStore::MessageFragmentStore(
_fs._sc.registerSerializerJson<FragComp::MessagesTSRange>(serl_json_msg_ts_range); _fs._sc.registerSerializerJson<FragComp::MessagesTSRange>(serl_json_msg_ts_range);
_sc.registerSerializerJson<Message::Components::Timestamp>(serl_json_default<Message::Components::Timestamp>); _sc.registerSerializerJson<Message::Components::Timestamp>(serl_json_default<Message::Components::Timestamp>);
_sc.registerSerializerJson<Message::Components::TimestampProcessed>(serl_json_default<Message::Components::TimestampProcessed>);
_sc.registerSerializerJson<Message::Components::TimestampWritten>(serl_json_default<Message::Components::TimestampWritten>);
_sc.registerSerializerJson<Message::Components::ContactFrom>(serl_json_default<Message::Components::ContactFrom>); _sc.registerSerializerJson<Message::Components::ContactFrom>(serl_json_default<Message::Components::ContactFrom>);
_sc.registerSerializerJson<Message::Components::ContactTo>(serl_json_default<Message::Components::ContactTo>); _sc.registerSerializerJson<Message::Components::ContactTo>(serl_json_default<Message::Components::ContactTo>);
_sc.registerSerializerJson<Message::Components::TagUnread>(serl_json_default<Message::Components::TagUnread>);
_sc.registerSerializerJson<Message::Components::Read>(serl_json_default<Message::Components::Read>);
_sc.registerSerializerJson<Message::Components::MessageText>(serl_json_default<Message::Components::MessageText>); _sc.registerSerializerJson<Message::Components::MessageText>(serl_json_default<Message::Components::MessageText>);
_sc.registerSerializerJson<Message::Components::TagMessageIsAction>(serl_json_default<Message::Components::TagMessageIsAction>); _sc.registerSerializerJson<Message::Components::TagMessageIsAction>(serl_json_default<Message::Components::TagMessageIsAction>);
// files // files
//_sc.registerSerializerJson<Message::Components::Transfer::FileID>() //_sc.registerSerializerJson<Message::Components::Transfer::FileID>()
//_sc.registerSerializerJson<Message::Components::Transfer::FileInfo>(); _sc.registerSerializerJson<Message::Components::Transfer::FileInfo>(serl_json_default<Message::Components::Transfer::FileInfo>);
//_sc.registerSerializerJson<Message::Components::Transfer::FileInfoLocal>(); _sc.registerSerializerJson<Message::Components::Transfer::FileInfoLocal>(serl_json_default<Message::Components::Transfer::FileInfoLocal>);
//_sc.registerSerializerJson<Message::Components::Transfer::TagHaveAll>(); _sc.registerSerializerJson<Message::Components::Transfer::TagHaveAll>(serl_json_default<Message::Components::Transfer::TagHaveAll>);
} }
MessageFragmentStore::~MessageFragmentStore(void) { MessageFragmentStore::~MessageFragmentStore(void) {
@ -228,6 +240,7 @@ float MessageFragmentStore::tick(float time_delta) {
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";
continue; continue;
} }

View File

@ -31,6 +31,10 @@ namespace Fragment::Components {
}; };
} // Fragment::Components } // Fragment::Components
struct MessageSerializerCallbacks : public SerializerCallbacks {
// TODO: add contact and message reg, so entities can be looked up and be converted to fragment uids OR persistent ids
};
// handles fragments for messages // handles fragments for messages
// on new message: assign fuid // on new message: assign fuid
// on new and update: mark as fragment dirty // on new and update: mark as fragment dirty
@ -41,7 +45,7 @@ class MessageFragmentStore : public RegistryMessageModelEventI {
FragmentStore& _fs; FragmentStore& _fs;
// for message components only // for message components only
SerializerCallbacks _sc; MessageSerializerCallbacks _sc;
void handleMessage(const Message3Handle& m); void handleMessage(const Message3Handle& m);