]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/llvm/tools/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.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/FormatNavigator.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         Clear ();
69         
70         bool
71         Get (KeyType name,
72              ValueSP& entry);
73         
74         bool
75         Get (uint32_t pos,
76              ValueSP& entry);
77         
78         void
79         LoopThrough (CallbackType callback, void* param);
80         
81         lldb::TypeCategoryImplSP
82         GetAtIndex (uint32_t);
83         
84         bool
85         AnyMatches (ConstString type_name,
86                     TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
87                     bool only_enabled = true,
88                     const char** matching_category = NULL,
89                     TypeCategoryImpl::FormatCategoryItems* matching_type = NULL);
90         
91         uint32_t
92         GetCount ()
93         {
94             return m_map.size();
95         }
96         
97         lldb::TypeSummaryImplSP
98         GetSummaryFormat (ValueObject& valobj,
99                           lldb::DynamicValueType use_dynamic);
100         
101 #ifndef LLDB_DISABLE_PYTHON
102         lldb::SyntheticChildrenSP
103         GetSyntheticChildren (ValueObject& valobj,
104                               lldb::DynamicValueType use_dynamic);
105 #endif
106         
107     private:
108         
109         class delete_matching_categories
110         {
111             lldb::TypeCategoryImplSP ptr;
112         public:
113             delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p)
114             {}
115             
116             bool operator()(const lldb::TypeCategoryImplSP& other)
117             {
118                 return ptr.get() == other.get();
119             }
120         };
121         
122         Mutex m_map_mutex;
123         IFormatChangeListener* listener;
124         
125         MapType m_map;
126         ActiveCategoriesList m_active_categories;
127         
128         MapType& map ()
129         {
130             return m_map;
131         }
132         
133         ActiveCategoriesList& active_list ()
134         {
135             return m_active_categories;
136         }
137         
138         Mutex& mutex ()
139         {
140             return m_map_mutex;
141         }
142         
143         friend class FormatNavigator<KeyType, ValueType>;
144         friend class FormatManager;
145     };
146 } // namespace lldb_private
147
148 #endif  // lldb_TypeCategoryMap_h_