1 //===-- TypeCategoryMap.h ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_TypeCategoryMap_h_
11 #define lldb_TypeCategoryMap_h_
18 #include "lldb/lldb-enumerations.h"
19 #include "lldb/lldb-public.h"
21 #include "lldb/DataFormatters/FormattersContainer.h"
22 #include "lldb/DataFormatters/TypeCategory.h"
24 namespace lldb_private {
25 class TypeCategoryMap {
27 typedef ConstString KeyType;
28 typedef TypeCategoryImpl ValueType;
29 typedef ValueType::SharedPointer ValueSP;
30 typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
31 typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
34 typedef std::map<KeyType, ValueSP> MapType;
35 typedef MapType::iterator MapIterator;
36 typedef std::function<bool(const ValueSP &)> ForEachCallback;
38 typedef uint32_t Position;
40 static const Position First = 0;
41 static const Position Default = 1;
42 static const Position Last = UINT32_MAX;
44 TypeCategoryMap(IFormatChangeListener *lst);
46 void Add(KeyType name, const ValueSP &entry);
48 bool Delete(KeyType name);
50 bool Enable(KeyType category_name, Position pos = Default);
52 bool Disable(KeyType category_name);
54 bool Enable(ValueSP category, Position pos = Default);
56 bool Disable(ValueSP category);
58 void EnableAllCategories();
60 void DisableAllCategories();
64 bool Get(KeyType name, ValueSP &entry);
66 bool Get(uint32_t pos, ValueSP &entry);
68 void ForEach(ForEachCallback callback);
70 lldb::TypeCategoryImplSP GetAtIndex(uint32_t);
73 AnyMatches(ConstString type_name,
74 TypeCategoryImpl::FormatCategoryItems items =
75 TypeCategoryImpl::ALL_ITEM_TYPES,
76 bool only_enabled = true, const char **matching_category = nullptr,
77 TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
79 uint32_t GetCount() { return m_map.size(); }
81 lldb::TypeFormatImplSP GetFormat(FormattersMatchData &match_data);
83 lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data);
85 #ifndef LLDB_DISABLE_PYTHON
86 lldb::SyntheticChildrenSP
87 GetSyntheticChildren(FormattersMatchData &match_data);
90 lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data);
93 class delete_matching_categories {
94 lldb::TypeCategoryImplSP ptr;
97 delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p) {}
99 bool operator()(const lldb::TypeCategoryImplSP &other) {
100 return ptr.get() == other.get();
104 std::recursive_mutex m_map_mutex;
105 IFormatChangeListener *listener;
108 ActiveCategoriesList m_active_categories;
110 MapType &map() { return m_map; }
112 ActiveCategoriesList &active_list() { return m_active_categories; }
114 std::recursive_mutex &mutex() { return m_map_mutex; }
116 friend class FormattersContainer<KeyType, ValueType>;
117 friend class FormatManager;
119 } // namespace lldb_private
121 #endif // lldb_TypeCategoryMap_h_