1 //===-- FormatCache.h ---------------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef lldb_FormatCache_h_
12 #define lldb_FormatCache_h_
17 #include "lldb/Utility/ConstString.h"
18 #include "lldb/lldb-public.h"
20 namespace lldb_private {
25 bool m_format_cached : 1;
26 bool m_summary_cached : 1;
27 bool m_synthetic_cached : 1;
28 bool m_validator_cached : 1;
30 lldb::TypeFormatImplSP m_format_sp;
31 lldb::TypeSummaryImplSP m_summary_sp;
32 lldb::SyntheticChildrenSP m_synthetic_sp;
33 lldb::TypeValidatorImplSP m_validator_sp;
37 Entry(lldb::TypeFormatImplSP);
38 Entry(lldb::TypeSummaryImplSP);
39 Entry(lldb::SyntheticChildrenSP);
40 Entry(lldb::TypeValidatorImplSP);
41 Entry(lldb::TypeFormatImplSP, lldb::TypeSummaryImplSP,
42 lldb::SyntheticChildrenSP, lldb::TypeValidatorImplSP);
44 bool IsFormatCached();
46 bool IsSummaryCached();
48 bool IsSyntheticCached();
50 bool IsValidatorCached();
52 lldb::TypeFormatImplSP GetFormat();
54 lldb::TypeSummaryImplSP GetSummary();
56 lldb::SyntheticChildrenSP GetSynthetic();
58 lldb::TypeValidatorImplSP GetValidator();
60 void SetFormat(lldb::TypeFormatImplSP);
62 void SetSummary(lldb::TypeSummaryImplSP);
64 void SetSynthetic(lldb::SyntheticChildrenSP);
66 void SetValidator(lldb::TypeValidatorImplSP);
68 typedef std::map<ConstString, Entry> CacheMap;
70 std::recursive_mutex m_mutex;
72 uint64_t m_cache_hits;
73 uint64_t m_cache_misses;
75 Entry &GetEntry(const ConstString &type);
80 bool GetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
82 bool GetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
84 bool GetSynthetic(const ConstString &type,
85 lldb::SyntheticChildrenSP &synthetic_sp);
87 bool GetValidator(const ConstString &type,
88 lldb::TypeValidatorImplSP &summary_sp);
90 void SetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
92 void SetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
94 void SetSynthetic(const ConstString &type,
95 lldb::SyntheticChildrenSP &synthetic_sp);
97 void SetValidator(const ConstString &type,
98 lldb::TypeValidatorImplSP &synthetic_sp);
102 uint64_t GetCacheHits() { return m_cache_hits; }
104 uint64_t GetCacheMisses() { return m_cache_misses; }
106 } // namespace lldb_private
108 #endif // lldb_FormatCache_h_