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