From 329dd0af0b71e8447a885472f4500ebeca965fb5 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 8 Nov 2014 18:15:31 -0500 Subject: [PATCH] Debugger: Extend ExpressionInfo. - Add setters for the individual subcomponents. - Add listener interface. This will supplant the one currently attached to Team. --- src/apps/debugger/model/ExpressionInfo.cpp | 49 +++++++++++++++++++++- src/apps/debugger/model/ExpressionInfo.h | 28 ++++++++++++- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/apps/debugger/model/ExpressionInfo.cpp b/src/apps/debugger/model/ExpressionInfo.cpp index 0b2a58846f..bdbfab7f9b 100644 --- a/src/apps/debugger/model/ExpressionInfo.cpp +++ b/src/apps/debugger/model/ExpressionInfo.cpp @@ -29,8 +29,7 @@ ExpressionInfo::ExpressionInfo(const ExpressionInfo& other) ExpressionInfo::~ExpressionInfo() { - if (fResultType != NULL) - fResultType->ReleaseReference(); + SetResultType(NULL); } @@ -46,8 +45,22 @@ ExpressionInfo::ExpressionInfo(const BString& expression, Type* resultType) void ExpressionInfo::SetTo(const BString& expression, Type* resultType) +{ + SetExpression(expression); + SetResultType(resultType); +} + + +void +ExpressionInfo::SetExpression(const BString& expression) { fExpression = expression; +} + + +void +ExpressionInfo::SetResultType(Type* resultType) +{ if (fResultType != NULL) fResultType->ReleaseReference(); @@ -55,3 +68,35 @@ ExpressionInfo::SetTo(const BString& expression, Type* resultType) if (fResultType != NULL) fResultType->AcquireReference(); } + + +void +ExpressionInfo::AddListener(Listener* listener) +{ + fListeners.Add(listener); +} + + +void +ExpressionInfo::RemoveListener(Listener* listener) +{ + fListeners.Remove(listener); +} + + +void +ExpressionInfo::NotifyExpressionEvaluated(status_t result, Value* value) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + Listener* listener = it.Next();) { + listener->ExpressionEvaluated(this, result, value); + } +} + + +// #pragma mark - ExpressionInfo::Listener + + +ExpressionInfo::Listener::~Listener() +{ +} diff --git a/src/apps/debugger/model/ExpressionInfo.h b/src/apps/debugger/model/ExpressionInfo.h index 8e3411a619..33c5e8bea1 100644 --- a/src/apps/debugger/model/ExpressionInfo.h +++ b/src/apps/debugger/model/ExpressionInfo.h @@ -9,12 +9,16 @@ #include #include - +#include class Type; +class Value; class ExpressionInfo : public BReferenceable { +public: + class Listener; + public: ExpressionInfo(); ExpressionInfo(const ExpressionInfo& other); @@ -26,11 +30,33 @@ public: Type* resultType); const BString& Expression() const { return fExpression; } + void SetExpression(const BString& expression); + Type* ResultType() const { return fResultType; } + void SetResultType(Type* resultType); + + void AddListener(Listener* listener); + void RemoveListener(Listener* listener); + + void NotifyExpressionEvaluated(status_t result, + Value* value); + +private: + typedef DoublyLinkedList ListenerList; private: BString fExpression; Type* fResultType; + ListenerList fListeners; +}; + + +class ExpressionInfo::Listener : public DoublyLinkedListLinkImpl { +public: + virtual ~Listener(); + + virtual void ExpressionEvaluated(ExpressionInfo* info, + status_t result, Value* value) = 0; };