managed subscribtions

This commit is contained in:
Green Sky 2024-10-24 01:03:16 +02:00
parent a6c5886fb6
commit c42c446446
No known key found for this signature in database
2 changed files with 12 additions and 6 deletions

View File

@ -485,10 +485,12 @@ MessageFragmentStore::MessageFragmentStore(
ObjectStore2& os, ObjectStore2& os,
StorageBackendI& sb, StorageBackendI& sb,
MessageSerializerNJ& scnj MessageSerializerNJ& scnj
) : _cr(cr), _rmm(rmm), _os(os), _sb(sb), _scnj(scnj) { ) : _cr(cr), _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _os(os), _os_sr(_os.newSubRef(this)), _sb(sb), _scnj(scnj) {
_rmm.subscribe(this, RegistryMessageModel_Event::message_construct); _rmm_sr
_rmm.subscribe(this, RegistryMessageModel_Event::message_updated); .subscribe(RegistryMessageModel_Event::message_construct)
_rmm.subscribe(this, RegistryMessageModel_Event::message_destroy); .subscribe(RegistryMessageModel_Event::message_updated)
.subscribe(RegistryMessageModel_Event::message_destroy)
;
// TODO: move somewhere else? // TODO: move somewhere else?
auto& sjc = _os.registry().ctx().get<SerializerJsonCallbacks<Object>>(); auto& sjc = _os.registry().ctx().get<SerializerJsonCallbacks<Object>>();
@ -505,8 +507,10 @@ MessageFragmentStore::MessageFragmentStore(
sjc.registerSerializer<FragComp::MessagesContact>(sjc.component_get_json<ObjComp::MessagesContact>); sjc.registerSerializer<FragComp::MessagesContact>(sjc.component_get_json<ObjComp::MessagesContact>);
sjc.registerDeSerializer<FragComp::MessagesContact>(sjc.component_emplace_or_replace_json<ObjComp::MessagesContact>); sjc.registerDeSerializer<FragComp::MessagesContact>(sjc.component_emplace_or_replace_json<ObjComp::MessagesContact>);
_os.subscribe(this, ObjectStore_Event::object_construct); _os_sr
_os.subscribe(this, ObjectStore_Event::object_update); .subscribe(ObjectStore_Event::object_construct)
.subscribe(ObjectStore_Event::object_update)
;
} }
MessageFragmentStore::~MessageFragmentStore(void) { MessageFragmentStore::~MessageFragmentStore(void) {

View File

@ -52,7 +52,9 @@ class MessageFragmentStore : public RegistryMessageModelEventI, public ObjectSto
protected: protected:
Contact3Registry& _cr; Contact3Registry& _cr;
RegistryMessageModelI& _rmm; RegistryMessageModelI& _rmm;
RegistryMessageModelI::SubscriptionReference _rmm_sr;
ObjectStore2& _os; ObjectStore2& _os;
ObjectStore2::SubscriptionReference _os_sr;
StorageBackendI& _sb; StorageBackendI& _sb;
MessageSerializerNJ& _scnj; MessageSerializerNJ& _scnj;