2014-11-05 07:06:59 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2014, Rene Gollent, rene@gollent.com.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef EXPRESSION_INFO_H
|
|
|
|
#define EXPRESSION_INFO_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
#include <Referenceable.h>
|
2014-11-09 02:15:31 +03:00
|
|
|
#include <util/DoublyLinkedList.h>
|
2014-11-05 07:06:59 +03:00
|
|
|
|
|
|
|
class Type;
|
2014-11-09 02:15:31 +03:00
|
|
|
class Value;
|
2014-11-05 07:06:59 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ExpressionInfo : public BReferenceable {
|
2014-11-09 02:15:31 +03:00
|
|
|
public:
|
|
|
|
class Listener;
|
|
|
|
|
2014-11-05 07:06:59 +03:00
|
|
|
public:
|
|
|
|
ExpressionInfo();
|
|
|
|
ExpressionInfo(const ExpressionInfo& other);
|
|
|
|
ExpressionInfo(const BString& expression,
|
|
|
|
Type* resultType);
|
|
|
|
virtual ~ExpressionInfo();
|
|
|
|
|
|
|
|
void SetTo(const BString& expression,
|
|
|
|
Type* resultType);
|
|
|
|
|
|
|
|
const BString& Expression() const { return fExpression; }
|
2014-11-09 02:15:31 +03:00
|
|
|
void SetExpression(const BString& expression);
|
|
|
|
|
2014-11-05 07:06:59 +03:00
|
|
|
Type* ResultType() const { return fResultType; }
|
2014-11-09 02:15:31 +03:00
|
|
|
void SetResultType(Type* resultType);
|
|
|
|
|
|
|
|
void AddListener(Listener* listener);
|
|
|
|
void RemoveListener(Listener* listener);
|
|
|
|
|
|
|
|
void NotifyExpressionEvaluated(status_t result,
|
|
|
|
Value* value);
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef DoublyLinkedList<Listener> ListenerList;
|
2014-11-05 07:06:59 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
BString fExpression;
|
|
|
|
Type* fResultType;
|
2014-11-09 02:15:31 +03:00
|
|
|
ListenerList fListeners;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpressionInfo::Listener : public DoublyLinkedListLinkImpl<Listener> {
|
|
|
|
public:
|
|
|
|
virtual ~Listener();
|
|
|
|
|
|
|
|
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
|
|
|
status_t result, Value* value) = 0;
|
2014-11-05 07:06:59 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // EXPRESSION_INFO_H
|