]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/DataFormatters/FormatCache.h
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / include / lldb / DataFormatters / FormatCache.h
1 //===-- FormatCache.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 lldb_FormatCache_h_
11 #define lldb_FormatCache_h_
12
13 // C Includes
14 // C++ Includes
15 #include <map>
16 #include <mutex>
17
18 // Other libraries and framework includes
19 // Project includes
20 #include "lldb/lldb-public.h"
21 #include "lldb/Core/ConstString.h"
22
23 namespace lldb_private {
24 class FormatCache
25 {
26 private:
27     struct Entry
28     {
29     private:
30         bool m_format_cached : 1;
31         bool m_summary_cached : 1;
32         bool m_synthetic_cached : 1;
33         bool m_validator_cached : 1;
34         
35         lldb::TypeFormatImplSP m_format_sp;
36         lldb::TypeSummaryImplSP m_summary_sp;
37         lldb::SyntheticChildrenSP m_synthetic_sp;
38         lldb::TypeValidatorImplSP m_validator_sp;
39     public:
40         Entry ();
41         Entry (lldb::TypeFormatImplSP);
42         Entry (lldb::TypeSummaryImplSP);
43         Entry (lldb::SyntheticChildrenSP);
44         Entry (lldb::TypeValidatorImplSP);
45         Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP,lldb::TypeValidatorImplSP);
46
47         bool
48         IsFormatCached ();
49         
50         bool
51         IsSummaryCached ();
52         
53         bool
54         IsSyntheticCached ();
55         
56         bool
57         IsValidatorCached ();
58         
59         lldb::TypeFormatImplSP
60         GetFormat ();
61         
62         lldb::TypeSummaryImplSP
63         GetSummary ();
64         
65         lldb::SyntheticChildrenSP
66         GetSynthetic ();
67         
68         lldb::TypeValidatorImplSP
69         GetValidator ();
70         
71         void
72         SetFormat (lldb::TypeFormatImplSP);
73         
74         void
75         SetSummary (lldb::TypeSummaryImplSP);
76         
77         void
78         SetSynthetic (lldb::SyntheticChildrenSP);
79         
80         void
81         SetValidator (lldb::TypeValidatorImplSP);
82     };
83     typedef std::map<ConstString,Entry> CacheMap;
84     CacheMap m_map;
85     std::recursive_mutex m_mutex;
86
87     uint64_t m_cache_hits;
88     uint64_t m_cache_misses;
89     
90     Entry&
91     GetEntry (const ConstString& type);
92     
93 public:
94     FormatCache ();
95     
96     bool
97     GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp);
98     
99     bool
100     GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
101
102     bool
103     GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
104     
105     bool
106     GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& summary_sp);
107     
108     void
109     SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp);
110     
111     void
112     SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
113     
114     void
115     SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
116     
117     void
118     SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& synthetic_sp);
119     
120     void
121     Clear ();
122     
123     uint64_t
124     GetCacheHits ()
125     {
126         return m_cache_hits;
127     }
128     
129     uint64_t
130     GetCacheMisses ()
131     {
132         return m_cache_misses;
133     }
134 };
135 } // namespace lldb_private
136
137 #endif  // lldb_FormatCache_h_