2 * Copyright 2014, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
5 #ifndef EXPRESSION_INFO_H
6 #define EXPRESSION_INFO_H
11 #include <Referenceable.h>
12 #include <util/DoublyLinkedList.h>
21 enum expression_result_kind
{
22 EXPRESSION_RESULT_KIND_UNKNOWN
= 0,
23 EXPRESSION_RESULT_KIND_PRIMITIVE
,
24 EXPRESSION_RESULT_KIND_VALUE_NODE
,
25 EXPRESSION_RESULT_KIND_TYPE
29 class ExpressionResult
: public BReferenceable
{
32 virtual ~ExpressionResult();
35 expression_result_kind
Kind() const { return fResultKind
; }
37 Value
* PrimitiveValue() const
38 { return fPrimitiveValue
; }
39 ValueNodeChild
* ValueNodeValue() const
40 { return fValueNodeValue
; }
42 { return fTypeResult
; }
44 void SetToPrimitive(Value
* value
);
45 void SetToValueNode(ValueNodeChild
* child
);
46 void SetToType(Type
* type
);
51 expression_result_kind fResultKind
;
52 Value
* fPrimitiveValue
;
53 ValueNodeChild
* fValueNodeValue
;
58 class ExpressionInfo
: public BReferenceable
{
64 ExpressionInfo(const ExpressionInfo
& other
);
65 ExpressionInfo(const BString
& expression
);
66 virtual ~ExpressionInfo();
68 void SetTo(const BString
& expression
);
70 const BString
& Expression() const { return fExpression
; }
72 void AddListener(Listener
* listener
);
73 void RemoveListener(Listener
* listener
);
75 void NotifyExpressionEvaluated(status_t result
,
76 ExpressionResult
* value
);
79 typedef DoublyLinkedList
<Listener
> ListenerList
;
83 ListenerList fListeners
;
87 class ExpressionInfo::Listener
: public DoublyLinkedListLinkImpl
<Listener
> {
91 virtual void ExpressionEvaluated(ExpressionInfo
* info
,
93 ExpressionResult
* value
) = 0;
97 #endif // EXPRESSION_INFO_H