mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
feat(MainDb): add a weak list of event references
This commit is contained in:
parent
057db03349
commit
9d4a1f3cd5
5 changed files with 15 additions and 4 deletions
|
|
@ -38,6 +38,7 @@ class LINPHONE_PUBLIC Core : public Object {
|
|||
friend class ChatRoom;
|
||||
friend class ClientGroupChatRoom;
|
||||
friend class MainDb;
|
||||
friend class MainDbEventKey;
|
||||
|
||||
public:
|
||||
L_OVERRIDE_SHARED_FROM_THIS(Core);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "core/core-p.h"
|
||||
#include "main-db-event-key-p.h"
|
||||
#include "main-db-p.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -44,9 +46,10 @@ MainDbEventKey::MainDbEventKey (const MainDbEventKey &src) : MainDbEventKey() {
|
|||
}
|
||||
|
||||
MainDbEventKey::~MainDbEventKey () {
|
||||
if (isValid()) {
|
||||
// TODO: Remove key from main db references if necessary.
|
||||
}
|
||||
L_D();
|
||||
|
||||
if (isValid())
|
||||
d->core.lock()->getPrivate()->mainDb->getPrivate()->storageIdToEvent.erase(d->storageId);
|
||||
}
|
||||
|
||||
MainDbEventKey &MainDbEventKey::operator= (const MainDbEventKey &src) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
class Content;
|
||||
|
||||
class MainDbPrivate : public AbstractDbPrivate {
|
||||
public:
|
||||
std::unordered_map<long long, std::weak_ptr<EventLog>> storageIdToEvent;
|
||||
|
||||
private:
|
||||
// ---------------------------------------------------------------------------
|
||||
// Low level API.
|
||||
|
|
|
|||
|
|
@ -833,8 +833,10 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
|
||||
L_END_LOG_EXCEPTION
|
||||
|
||||
if (soFarSoGood)
|
||||
if (soFarSoGood) {
|
||||
dEventLog->dbKey = MainDbEventKey(getCore(), storageId);
|
||||
d->storageIdToEvent[storageId] = eventLog;
|
||||
}
|
||||
|
||||
return soFarSoGood;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ class EventLog;
|
|||
class MainDbPrivate;
|
||||
|
||||
class MainDb : public AbstractDb, public CoreAccessor {
|
||||
friend class MainDbEventKey;
|
||||
|
||||
public:
|
||||
enum Filter {
|
||||
NoFilter = 0x0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue