ValueObjectSyntheticFilter.h revision 3d656c729a1ed0abad4e5a2d76f6e8a6904f66aa
1//===-- ValueObjectSyntheticFilter.h -------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_ValueObjectSyntheticFilter_h_ 11#define liblldb_ValueObjectSyntheticFilter_h_ 12 13// C Includes 14// C++ Includes 15#include <map> 16#include <vector> 17// Other libraries and framework includes 18// Project includes 19#include "lldb/Core/ValueObject.h" 20 21namespace lldb_private { 22 23//---------------------------------------------------------------------- 24// A ValueObject that obtains its children from some source other than 25// real information 26// This is currently used to implement Python-based children and filters 27// but you can bind it to any source of synthetic information and have 28// it behave accordingly 29//---------------------------------------------------------------------- 30class ValueObjectSynthetic : public ValueObject 31{ 32public: 33 virtual 34 ~ValueObjectSynthetic(); 35 36 virtual size_t 37 GetByteSize(); 38 39 virtual ConstString 40 GetTypeName(); 41 42 virtual uint32_t 43 CalculateNumChildren(); 44 45 virtual lldb::ValueType 46 GetValueType() const; 47 48 virtual lldb::ValueObjectSP 49 GetChildAtIndex (uint32_t idx, bool can_create); 50 51 virtual lldb::ValueObjectSP 52 GetChildMemberWithName (const ConstString &name, bool can_create); 53 54 virtual uint32_t 55 GetIndexOfChildWithName (const ConstString &name); 56 57 virtual bool 58 IsInScope (); 59 60 virtual bool 61 HasSyntheticValue() 62 { 63 return false; 64 } 65 66 virtual bool 67 IsSynthetic() { return true; } 68 69 virtual void 70 CalculateSyntheticValue (bool use_synthetic) 71 { 72 } 73 74 virtual bool 75 IsDynamic () 76 { 77 if (m_parent) 78 return m_parent->IsDynamic(); 79 else 80 return false; 81 } 82 83 virtual ValueObject * 84 GetParent() 85 { 86 if (m_parent) 87 return m_parent->GetParent(); 88 else 89 return NULL; 90 } 91 92 virtual const ValueObject * 93 GetParent() const 94 { 95 if (m_parent) 96 return m_parent->GetParent(); 97 else 98 return NULL; 99 } 100 101 virtual lldb::ValueObjectSP 102 GetNonSyntheticValue (); 103 104 virtual bool 105 ResolveValue (Scalar &scalar) 106 { 107 if (m_parent) 108 return m_parent->ResolveValue(scalar); 109 return false; 110 } 111 112protected: 113 virtual bool 114 UpdateValue (); 115 116 virtual clang::ASTContext * 117 GetClangASTImpl (); 118 119 virtual lldb::clang_type_t 120 GetClangTypeImpl (); 121 122 virtual void 123 CreateSynthFilter (); 124 125 // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive 126 lldb::SyntheticChildrenSP m_synth_sp; 127 std::auto_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap; 128 129 typedef std::map<uint32_t, ValueObject*> ByIndexMap; 130 typedef std::map<const char*, uint32_t> NameToIndexMap; 131 132 typedef ByIndexMap::iterator ByIndexIterator; 133 typedef NameToIndexMap::iterator NameToIndexIterator; 134 135 ByIndexMap m_children_byindex; 136 NameToIndexMap m_name_toindex; 137 uint32_t m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution 138 139 ConstString m_parent_type_name; 140 141private: 142 friend class ValueObject; 143 ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter); 144 145 void 146 CopyParentData (); 147 148 //------------------------------------------------------------------ 149 // For ValueObject only 150 //------------------------------------------------------------------ 151 DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic); 152}; 153 154} // namespace lldb_private 155 156#endif // liblldb_ValueObjectSyntheticFilter_h_ 157