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_
20 // Other libraries and framework includes
22 #include "lldb/lldb-enumerations.h"
23 #include "lldb/lldb-public.h"
25 #include "lldb/DataFormatters/FormattersContainer.h"
26 #include "lldb/DataFormatters/TypeCategory.h"
28 namespace lldb_private {
29 class TypeCategoryMap {
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;
38 typedef std::map<KeyType, ValueSP> MapType;
39 typedef MapType::iterator MapIterator;
40 typedef std::function<bool(const ValueSP &)> ForEachCallback;
42 typedef uint32_t Position;
44 static const Position First = 0;
45 static const Position Default = 1;
46 static const Position Last = UINT32_MAX;
48 TypeCategoryMap(IFormatChangeListener *lst);
50 void Add(KeyType name, const ValueSP &entry);
52 bool Delete(KeyType name);
54 bool Enable(KeyType category_name, Position pos = Default);
56 bool Disable(KeyType category_name);
58 bool Enable(ValueSP category, Position pos = Default);
60 bool Disable(ValueSP category);
62 void EnableAllCategories();
64 void DisableAllCategories();
68 bool Get(KeyType name, ValueSP &entry);
70 bool Get(uint32_t pos, ValueSP &entry);
72 void ForEach(ForEachCallback callback);
74 lldb::TypeCategoryImplSP GetAtIndex(uint32_t);
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);
83 uint32_t GetCount() { return m_map.size(); }
85 lldb::TypeFormatImplSP GetFormat(FormattersMatchData &match_data);
87 lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data);
89 #ifndef LLDB_DISABLE_PYTHON
90 lldb::SyntheticChildrenSP
91 GetSyntheticChildren(FormattersMatchData &match_data);
94 lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data);
97 class delete_matching_categories {
98 lldb::TypeCategoryImplSP ptr;
101 delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p) {}
103 bool operator()(const lldb::TypeCategoryImplSP &other) {
104 return ptr.get() == other.get();
108 std::recursive_mutex m_map_mutex;
109 IFormatChangeListener *listener;
112 ActiveCategoriesList m_active_categories;
114 MapType &map() { return m_map; }
116 ActiveCategoriesList &active_list() { return m_active_categories; }
118 std::recursive_mutex &mutex() { return m_map_mutex; }
120 friend class FormattersContainer<KeyType, ValueType>;
121 friend class FormatManager;
123 } // namespace lldb_private
125 #endif // lldb_TypeCategoryMap_h_