1 /* 2 * Copyright 2013, 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 VARIABLES_VIEW_STATE_H 7 #define VARIABLES_VIEW_STATE_H 8 9 10 #include <Message.h> 11 #include <Referenceable.h> 12 #include <util/OpenHashTable.h> 13 14 15 class ObjectID; 16 class StackFrameValues; 17 class Type; 18 class TypeComponentPath; 19 20 21 class VariablesViewNodeInfo { 22 public: 23 VariablesViewNodeInfo(); 24 VariablesViewNodeInfo( 25 const VariablesViewNodeInfo& other); 26 virtual ~VariablesViewNodeInfo(); 27 28 VariablesViewNodeInfo& operator=( 29 const VariablesViewNodeInfo& other); 30 31 bool IsNodeExpanded() const 32 { return fNodeExpanded; } 33 void SetNodeExpanded(bool expanded); 34 35 Type* GetCastedType() const 36 { return fCastedType; } 37 void SetCastedType(Type* type); 38 39 const BMessage& GetRendererSettings() const 40 { return fRendererSettings; } 41 42 void SetRendererSettings(const BMessage& settings); 43 44 private: 45 bool fNodeExpanded; 46 Type* fCastedType; 47 BMessage fRendererSettings; 48 }; 49 50 51 class VariablesViewState : public BReferenceable { 52 public: 53 VariablesViewState(); 54 virtual ~VariablesViewState(); 55 56 status_t Init(); 57 58 StackFrameValues* Values() const 59 { return fValues; } 60 void SetValues(StackFrameValues* values); 61 62 const VariablesViewNodeInfo* GetNodeInfo(ObjectID* variable, 63 const TypeComponentPath* path) const; 64 inline const VariablesViewNodeInfo* GetNodeInfo(ObjectID* variable, 65 const TypeComponentPath& path) const; 66 67 status_t SetNodeInfo(ObjectID* variable, 68 TypeComponentPath* path, 69 const VariablesViewNodeInfo& info); 70 // requires an on-heap path 71 72 private: 73 struct Key; 74 struct InfoEntry; 75 struct InfoEntryHashDefinition; 76 77 typedef BOpenHashTable<InfoEntryHashDefinition> NodeInfoTable; 78 79 private: 80 void _Cleanup(); 81 82 private: 83 NodeInfoTable* fNodeInfos; 84 StackFrameValues* fValues; 85 }; 86 87 88 const VariablesViewNodeInfo* 89 VariablesViewState::GetNodeInfo(ObjectID* variable, 90 const TypeComponentPath& path) const 91 { 92 return GetNodeInfo(variable, &path); 93 } 94 95 96 #endif // VARIABLES_VIEW_STATE_H 97