]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
Upgrade Unbound to 1.7.0. More to follow.
[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 #include <functional>
16 #include <list>
17 #include <map>
18 #include <mutex>
19
20 // Other libraries and framework includes
21 // Project includes
22 #include "lldb/lldb-enumerations.h"
23 #include "lldb/lldb-public.h"
24
25 #include "lldb/DataFormatters/FormattersContainer.h"
26 #include "lldb/DataFormatters/TypeCategory.h"
27
28 namespace lldb_private {
29 class TypeCategoryMap {
30 private:
31   typedef ConstString KeyType;
32   typedef TypeCategoryImpl ValueType;
33   typedef ValueType::SharedPointer ValueSP;
34   typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
35   typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
36
37 public:
38   typedef std::map<KeyType, ValueSP> MapType;
39   typedef MapType::iterator MapIterator;
40   typedef std::function<bool(const ValueSP &)> ForEachCallback;
41
42   typedef uint32_t Position;
43
44   static const Position First = 0;
45   static const Position Default = 1;
46   static const Position Last = UINT32_MAX;
47
48   TypeCategoryMap(IFormatChangeListener *lst);
49
50   void Add(KeyType name, const ValueSP &entry);
51
52   bool Delete(KeyType name);
53
54   bool Enable(KeyType category_name, Position pos = Default);
55
56   bool Disable(KeyType category_name);
57
58   bool Enable(ValueSP category, Position pos = Default);
59
60   bool Disable(ValueSP category);
61
62   void EnableAllCategories();
63
64   void DisableAllCategories();
65
66   void Clear();
67
68   bool Get(KeyType name, ValueSP &entry);
69
70   bool Get(uint32_t pos, ValueSP &entry);
71
72   void ForEach(ForEachCallback callback);
73
74   lldb::TypeCategoryImplSP GetAtIndex(uint32_t);
75
76   bool
77   AnyMatches(ConstString type_name,
78              TypeCategoryImpl::FormatCategoryItems items =
79                  TypeCategoryImpl::ALL_ITEM_TYPES,
80              bool only_enabled = true, const char **matching_category = nullptr,
81              TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
82
83   uint32_t GetCount() { return m_map.size(); }
84
85   lldb::TypeFormatImplSP GetFormat(FormattersMatchData &match_data);
86
87   lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data);
88
89 #ifndef LLDB_DISABLE_PYTHON
90   lldb::SyntheticChildrenSP
91   GetSyntheticChildren(FormattersMatchData &match_data);
92 #endif
93
94   lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data);
95
96 private:
97   class delete_matching_categories {
98     lldb::TypeCategoryImplSP ptr;
99
100   public:
101     delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p) {}
102
103     bool operator()(const lldb::TypeCategoryImplSP &other) {
104       return ptr.get() == other.get();
105     }
106   };
107
108   std::recursive_mutex m_map_mutex;
109   IFormatChangeListener *listener;
110
111   MapType m_map;
112   ActiveCategoriesList m_active_categories;
113
114   MapType &map() { return m_map; }
115
116   ActiveCategoriesList &active_list() { return m_active_categories; }
117
118   std::recursive_mutex &mutex() { return m_map_mutex; }
119
120   friend class FormattersContainer<KeyType, ValueType>;
121   friend class FormatManager;
122 };
123 } // namespace lldb_private
124
125 #endif // lldb_TypeCategoryMap_h_