ValueObjectSyntheticFilter.h revision 4758a3ced524198d2cf9c50bab9b088adcbda9cb
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 104protected: 105 virtual bool 106 UpdateValue (); 107 108 virtual clang::ASTContext * 109 GetClangASTImpl (); 110 111 virtual lldb::clang_type_t 112 GetClangTypeImpl (); 113 114 // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive 115 lldb::SyntheticChildrenSP m_synth_sp; 116 std::auto_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap; 117 118 typedef std::map<uint32_t, ValueObject*> ByIndexMap; 119 typedef std::map<const char*, uint32_t> NameToIndexMap; 120 121 typedef ByIndexMap::iterator ByIndexIterator; 122 typedef NameToIndexMap::iterator NameToIndexIterator; 123 124 ByIndexMap m_children_byindex; 125 NameToIndexMap m_name_toindex; 126 uint32_t m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution 127 128private: 129 friend class ValueObject; 130 ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter); 131 132 //------------------------------------------------------------------ 133 // For ValueObject only 134 //------------------------------------------------------------------ 135 DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic); 136}; 137 138} // namespace lldb_private 139 140#endif // liblldb_ValueObjectSyntheticFilter_h_ 141