]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
Add ELF Tool Chain's ar(1) and elfdump(1) to contrib
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / DataFormatters / TypeCategoryMap.h
1 //===-- TypeCategoryMap.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_TypeCategoryMap_h_
11 #define lldb_TypeCategoryMap_h_
12
13 // C Includes
14 // C++ Includes
15
16 // Other libraries and framework includes
17 // Project includes
18 #include "lldb/lldb-public.h"
19 #include "lldb/lldb-enumerations.h"
20
21 #include "lldb/DataFormatters/FormattersContainer.h"
22 #include "lldb/DataFormatters/TypeCategory.h"
23
24 namespace lldb_private {
25     class TypeCategoryMap
26     {
27     private:
28         typedef ConstString KeyType;
29         typedef TypeCategoryImpl ValueType;
30         typedef ValueType::SharedPointer ValueSP;
31         typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
32         typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
33         
34     public:
35         typedef std::map<KeyType, ValueSP> MapType;
36         typedef MapType::iterator MapIterator;
37         typedef bool(*CallbackType)(void*, const ValueSP&);
38         typedef uint32_t Position;
39         
40         static const Position First = 0;
41         static const Position Default = 1;
42         static const Position Last = UINT32_MAX;
43         
44         TypeCategoryMap (IFormatChangeListener* lst);
45         
46         void
47         Add (KeyType name,
48              const ValueSP& entry);
49         
50         bool
51         Delete (KeyType name);
52         
53         bool
54         Enable (KeyType category_name,
55                 Position pos = Default);
56         
57         bool
58         Disable (KeyType category_name);
59         
60         bool
61         Enable (ValueSP category,
62                 Position pos = Default);
63         
64         bool
65         Disable (ValueSP category);
66
67         void
68         EnableAllCategories ();
69         
70         void
71         DisableAllCategories ();
72         
73         void
74         Clear ();
75         
76         bool
77         Get (KeyType name,
78              ValueSP& entry);
79         
80         bool
81         Get (uint32_t pos,
82              ValueSP& entry);
83         
84         void
85         LoopThrough (CallbackType callback, void* param);
86         
87         lldb::TypeCategoryImplSP
88         GetAtIndex (uint32_t);
89         
90         bool
91         AnyMatches (ConstString type_name,
92                     TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
93                     bool only_enabled = true,
94                     const char** matching_category = NULL,
95                     TypeCategoryImpl::FormatCategoryItems* matching_type = NULL);
96         
97         uint32_t
98         GetCount ()
99         {
100             return m_map.size();
101         }
102
103         lldb::TypeFormatImplSP
104         GetFormat (ValueObject& valobj,
105                    lldb::DynamicValueType use_dynamic);
106         
107         lldb::TypeSummaryImplSP
108         GetSummaryFormat (ValueObject& valobj,
109                           lldb::DynamicValueType use_dynamic);
110         
111 #ifndef LLDB_DISABLE_PYTHON
112         lldb::SyntheticChildrenSP
113         GetSyntheticChildren (ValueObject& valobj,
114                               lldb::DynamicValueType use_dynamic);
115 #endif
116         
117     lldb::TypeValidatorImplSP
118     GetValidator (ValueObject& valobj,
119                   lldb::DynamicValueType use_dynamic);
120         
121     private:
122         
123         class delete_matching_categories
124         {
125             lldb::TypeCategoryImplSP ptr;
126         public:
127             delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p)
128             {}
129             
130             bool operator()(const lldb::TypeCategoryImplSP& other)
131             {
132                 return ptr.get() == other.get();
133             }
134         };
135         
136         Mutex m_map_mutex;
137         IFormatChangeListener* listener;
138         
139         MapType m_map;
140         ActiveCategoriesList m_active_categories;
141         
142         MapType& map ()
143         {
144             return m_map;
145         }
146         
147         ActiveCategoriesList& active_list ()
148         {
149             return m_active_categories;
150         }
151         
152         Mutex& mutex ()
153         {
154             return m_map_mutex;
155         }
156         
157         friend class FormattersContainer<KeyType, ValueType>;
158         friend class FormatManager;
159     };
160 } // namespace lldb_private
161
162 #endif  // lldb_TypeCategoryMap_h_