xref: /haiku/headers/private/debugger/model/ExpressionValues.h (revision 5e7964b0a929555415798dea3373db9ac4611caa)
1 /*
2  * Copyright 2014, Rene Gollent, rene@gollent.com.
3  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef EXPRESSION_VALUES_H
7 #define EXPRESSION_VALUES_H
8 
9 
10 #include <String.h>
11 
12 #include <Referenceable.h>
13 #include <util/OpenHashTable.h>
14 #include <Variant.h>
15 
16 
17 class FunctionID;
18 class Thread;
19 
20 
21 class ExpressionValues : public BReferenceable {
22 public:
23 								ExpressionValues();
24 								ExpressionValues(const ExpressionValues& other);
25 									// throws std::bad_alloc
26 	virtual						~ExpressionValues();
27 
28 			status_t			Init();
29 
30 			bool				GetValue(FunctionID* function,
31 									Thread* thread,
32 									const BString* expression,
33 									BVariant& _value) const;
34 	inline	bool				GetValue(FunctionID* function,
35 									Thread* thread,
36 									const BString& expression,
37 									BVariant& _value) const;
38 			bool				HasValue(FunctionID* function,
39 									Thread* thread,
40 									const BString* expression) const;
41 	inline	bool				HasValue(FunctionID* function,
42 									Thread* thread,
43 									const BString& expression) const;
44 			status_t			SetValue(FunctionID* function,
45 									Thread* thread,
46 									const BString& expression,
47 									const BVariant& value);
48 
49 private:
50 			struct Key;
51 			struct ValueEntry;
52 			struct ValueEntryHashDefinition;
53 
54 			typedef BOpenHashTable<ValueEntryHashDefinition> ValueTable;
55 
56 private:
57 			ExpressionValues&	operator=(const ExpressionValues& other);
58 
59 			void				_Cleanup();
60 
61 private:
62 			ValueTable*			fValues;
63 };
64 
65 
66 bool
67 ExpressionValues::GetValue(FunctionID* function, Thread* thread,
68 	const BString& expression, BVariant& _value) const
69 {
70 	return GetValue(function, thread, &expression, _value);
71 }
72 
73 
74 bool
75 ExpressionValues::HasValue(FunctionID* function, Thread* thread,
76 	const BString& expression) const
77 {
78 	return HasValue(function, thread, &expression);
79 }
80 
81 
82 #endif	// EXPRESSION_VALUES_H
83