From e3bd3d8334683ab4d11a2ae9642416f39c31263b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 7 Nov 2011 18:41:29 +0000 Subject: [PATCH] Add methods {Add,Remove}AssociatedData() Allows to associate untyped data with the model, which the model free()s upon destruction. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43213 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debuganalyzer/model/Model.cpp | 17 +++++++++++++++++ src/apps/debuganalyzer/model/Model.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/apps/debuganalyzer/model/Model.cpp b/src/apps/debuganalyzer/model/Model.cpp index 0c24b3f8f4..f1e1f64b43 100644 --- a/src/apps/debuganalyzer/model/Model.cpp +++ b/src/apps/debuganalyzer/model/Model.cpp @@ -648,6 +648,9 @@ Model::~Model() delete[] fEvents; free(fEventData); + + for (int32 i = 0; void* data = fAssociatedData.ItemAt(i); i++) + free(data); } @@ -695,6 +698,20 @@ Model::ClosestEventIndex(nanotime_t eventTime) const } +bool +Model::AddAssociatedData(void* data) +{ + return fAssociatedData.AddItem(data); +} + + +void +Model::RemoveAssociatedData(void* data) +{ + fAssociatedData.RemoveItem(data); +} + + void Model::LoadingFinished() { diff --git a/src/apps/debuganalyzer/model/Model.h b/src/apps/debuganalyzer/model/Model.h index 6842f74875..cb0c6bb19f 100644 --- a/src/apps/debuganalyzer/model/Model.h +++ b/src/apps/debuganalyzer/model/Model.h @@ -71,6 +71,9 @@ public: // time >= eventTime; may return // CountEvents() + bool AddAssociatedData(void* data); + void RemoveAssociatedData(void* data); + void LoadingFinished(); inline nanotime_t BaseTime() const; @@ -160,6 +163,7 @@ private: WaitObjectGroupList fWaitObjectGroups; IOSchedulerList fIOSchedulers; SchedulingStateList fSchedulingStates; + BList fAssociatedData; };