1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef VARIABLES_VIEW_STATE_H 6 #define VARIABLES_VIEW_STATE_H 7 8 9 #include <Referenceable.h> 10 #include <util/OpenHashTable.h> 11 12 13 class ObjectID; 14 class StackFrameValues; 15 class TypeComponentPath; 16 17 18 class VariablesViewNodeInfo { 19 public: 20 VariablesViewNodeInfo(); 21 VariablesViewNodeInfo( 22 const VariablesViewNodeInfo& other); 23 24 VariablesViewNodeInfo& operator=( 25 const VariablesViewNodeInfo& other); 26 27 bool IsNodeExpanded() const 28 { return fNodeExpanded; } 29 void SetNodeExpanded(bool expanded); 30 31 private: 32 bool fNodeExpanded; 33 }; 34 35 36 class VariablesViewState : public BReferenceable { 37 public: 38 VariablesViewState(); 39 virtual ~VariablesViewState(); 40 41 status_t Init(); 42 43 StackFrameValues* Values() const 44 { return fValues; } 45 void SetValues(StackFrameValues* values); 46 47 const VariablesViewNodeInfo* GetNodeInfo(ObjectID* variable, 48 const TypeComponentPath* path) const; 49 inline const VariablesViewNodeInfo* GetNodeInfo(ObjectID* variable, 50 const TypeComponentPath& path) const; 51 52 status_t SetNodeInfo(ObjectID* variable, 53 TypeComponentPath* path, 54 const VariablesViewNodeInfo& info); 55 // requires an on-heap path 56 57 private: 58 struct Key; 59 struct InfoEntry; 60 struct InfoEntryHashDefinition; 61 62 typedef BOpenHashTable<InfoEntryHashDefinition> NodeInfoTable; 63 64 private: 65 void _Cleanup(); 66 67 private: 68 NodeInfoTable* fNodeInfos; 69 StackFrameValues* fValues; 70 }; 71 72 73 const VariablesViewNodeInfo* 74 VariablesViewState::GetNodeInfo(ObjectID* variable, 75 const TypeComponentPath& path) const 76 { 77 return GetNodeInfo(variable, &path); 78 } 79 80 81 #endif // VARIABLES_VIEW_STATE_H 82