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_
19 // Other libraries and framework includes
21 #include "lldb/Utility/ConstString.h"
22 #include "lldb/lldb-public.h"
24 namespace lldb_private {
29 bool m_format_cached : 1;
30 bool m_summary_cached : 1;
31 bool m_synthetic_cached : 1;
32 bool m_validator_cached : 1;
34 lldb::TypeFormatImplSP m_format_sp;
35 lldb::TypeSummaryImplSP m_summary_sp;
36 lldb::SyntheticChildrenSP m_synthetic_sp;
37 lldb::TypeValidatorImplSP m_validator_sp;
41 Entry(lldb::TypeFormatImplSP);
42 Entry(lldb::TypeSummaryImplSP);
43 Entry(lldb::SyntheticChildrenSP);
44 Entry(lldb::TypeValidatorImplSP);
45 Entry(lldb::TypeFormatImplSP, lldb::TypeSummaryImplSP,
46 lldb::SyntheticChildrenSP, lldb::TypeValidatorImplSP);
48 bool IsFormatCached();
50 bool IsSummaryCached();
52 bool IsSyntheticCached();
54 bool IsValidatorCached();
56 lldb::TypeFormatImplSP GetFormat();
58 lldb::TypeSummaryImplSP GetSummary();
60 lldb::SyntheticChildrenSP GetSynthetic();
62 lldb::TypeValidatorImplSP GetValidator();
64 void SetFormat(lldb::TypeFormatImplSP);
66 void SetSummary(lldb::TypeSummaryImplSP);
68 void SetSynthetic(lldb::SyntheticChildrenSP);
70 void SetValidator(lldb::TypeValidatorImplSP);
72 typedef std::map<ConstString, Entry> CacheMap;
74 std::recursive_mutex m_mutex;
76 uint64_t m_cache_hits;
77 uint64_t m_cache_misses;
79 Entry &GetEntry(const ConstString &type);
84 bool GetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
86 bool GetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
88 bool GetSynthetic(const ConstString &type,
89 lldb::SyntheticChildrenSP &synthetic_sp);
91 bool GetValidator(const ConstString &type,
92 lldb::TypeValidatorImplSP &summary_sp);
94 void SetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
96 void SetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
98 void SetSynthetic(const ConstString &type,
99 lldb::SyntheticChildrenSP &synthetic_sp);
101 void SetValidator(const ConstString &type,
102 lldb::TypeValidatorImplSP &synthetic_sp);
106 uint64_t GetCacheHits() { return m_cache_hits; }
108 uint64_t GetCacheMisses() { return m_cache_misses; }
110 } // namespace lldb_private
112 #endif // lldb_FormatCache_h_