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