Debugger: Extend ExpressionInfo.

- Add setters for the individual subcomponents.
- Add listener interface. This will supplant the one
  currently attached to Team.
This commit is contained in:
Rene Gollent 2014-11-08 18:15:31 -05:00
parent e646545b60
commit 329dd0af0b
2 changed files with 74 additions and 3 deletions

View File

@ -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()
{
}

View File

@ -9,12 +9,16 @@
#include <String.h>
#include <Referenceable.h>
#include <util/DoublyLinkedList.h>
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<Listener> ListenerList;
private:
BString fExpression;
Type* fResultType;
ListenerList fListeners;
};
class ExpressionInfo::Listener : public DoublyLinkedListLinkImpl<Listener> {
public:
virtual ~Listener();
virtual void ExpressionEvaluated(ExpressionInfo* info,
status_t result, Value* value) = 0;
};