LLDB  mainline
TypeCategoryMap.h
Go to the documentation of this file.
1 //===-- TypeCategoryMap.h ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H
10 #define LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H
11 
12 #include <functional>
13 #include <list>
14 #include <map>
15 #include <mutex>
16 
17 #include "lldb/lldb-enumerations.h"
18 #include "lldb/lldb-public.h"
19 
22 
23 namespace lldb_private {
25 private:
29  typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
30  typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
31 
32 public:
33  typedef std::map<KeyType, ValueSP> MapType;
34  typedef MapType::iterator MapIterator;
35  typedef std::function<bool(const ValueSP &)> ForEachCallback;
36 
37  typedef uint32_t Position;
38 
39  static const Position First = 0;
40  static const Position Default = 1;
41  static const Position Last = UINT32_MAX;
42 
44 
45  void Add(KeyType name, const ValueSP &entry);
46 
47  bool Delete(KeyType name);
48 
49  bool Enable(KeyType category_name, Position pos = Default);
50 
51  bool Disable(KeyType category_name);
52 
53  bool Enable(ValueSP category, Position pos = Default);
54 
55  bool Disable(ValueSP category);
56 
57  void EnableAllCategories();
58 
59  void DisableAllCategories();
60 
61  void Clear();
62 
63  bool Get(KeyType name, ValueSP &entry);
64 
65  bool Get(uint32_t pos, ValueSP &entry);
66 
67  void ForEach(ForEachCallback callback);
68 
69  lldb::TypeCategoryImplSP GetAtIndex(uint32_t);
70 
71  bool
72  AnyMatches(ConstString type_name,
75  bool only_enabled = true, const char **matching_category = nullptr,
76  TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
77 
78  uint32_t GetCount() { return m_map.size(); }
79 
80  template <typename ImplSP> void Get(FormattersMatchData &, ImplSP &);
81 
82 private:
84  lldb::TypeCategoryImplSP ptr;
85 
86  public:
87  delete_matching_categories(lldb::TypeCategoryImplSP p)
88  : ptr(std::move(p)) {}
89 
90  bool operator()(const lldb::TypeCategoryImplSP &other) {
91  return ptr.get() == other.get();
92  }
93  };
94 
95  std::recursive_mutex m_map_mutex;
97 
100 
101  MapType &map() { return m_map; }
102 
104 
105  std::recursive_mutex &mutex() { return m_map_mutex; }
106 
108  friend class FormatManager;
109 };
110 } // namespace lldb_private
111 
112 #endif // LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H
lldb_private::FormattersMatchData
Definition: FormatClasses.h:84
lldb_private::TypeCategoryMap::First
static const Position First
Definition: TypeCategoryMap.h:39
lldb_private::TypeCategoryMap::active_list
ActiveCategoriesList & active_list()
Definition: TypeCategoryMap.h:103
lldb-public.h
lldb_private::TypeCategoryMap::MapIterator
MapType::iterator MapIterator
Definition: TypeCategoryMap.h:34
lldb_private::FormatManager
Definition: FormatManager.h:36
lldb_private::TypeCategoryMap::delete_matching_categories
Definition: TypeCategoryMap.h:83
lldb_private::TypeCategoryMap::ActiveCategoriesIterator
ActiveCategoriesList::iterator ActiveCategoriesIterator
Definition: TypeCategoryMap.h:30
lldb_private::TypeCategoryMap::Enable
bool Enable(KeyType category_name, Position pos=Default)
Definition: TypeCategoryMap.cpp:46
lldb_private::TypeCategoryMap::delete_matching_categories::operator()
bool operator()(const lldb::TypeCategoryImplSP &other)
Definition: TypeCategoryMap.h:90
lldb_private::TypeCategoryImpl::ALL_ITEM_TYPES
static const uint16_t ALL_ITEM_TYPES
Definition: TypeCategory.h:72
lldb_private::FormattersContainer
Definition: FormattersContainer.h:107
lldb_private::TypeCategoryMap::AnyMatches
bool AnyMatches(ConstString type_name, TypeCategoryImpl::FormatCategoryItems items=TypeCategoryImpl::ALL_ITEM_TYPES, bool only_enabled=true, const char **matching_category=nullptr, TypeCategoryImpl::FormatCategoryItems *matching_type=nullptr)
Definition: TypeCategoryMap.cpp:156
lldb_private::TypeCategoryMap::map
MapType & map()
Definition: TypeCategoryMap.h:101
lldb_private::TypeCategoryMap::GetAtIndex
lldb::TypeCategoryImplSP GetAtIndex(uint32_t)
Definition: TypeCategoryMap.cpp:247
lldb_private::TypeCategoryMap
Definition: TypeCategoryMap.h:24
lldb_private::TypeCategoryMap::TypeCategoryMap
TypeCategoryMap(IFormatChangeListener *lst)
Definition: TypeCategoryMap.cpp:18
lldb_private::TypeCategoryMap::ForEachCallback
std::function< bool(const ValueSP &)> ForEachCallback
Definition: TypeCategoryMap.h:35
lldb_private::TypeCategoryMap::mutex
std::recursive_mutex & mutex()
Definition: TypeCategoryMap.h:105
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::TypeCategoryMap::EnableAllCategories
void EnableAllCategories()
Definition: TypeCategoryMap.cpp:94
lldb_private::TypeCategoryMap::Default
static const Position Default
Definition: TypeCategoryMap.h:40
lldb-enumerations.h
lldb_private::TypeCategoryMap::ValueSP
ValueType::SharedPointer ValueSP
Definition: TypeCategoryMap.h:28
lldb_private::TypeCategoryMap::Position
uint32_t Position
Definition: TypeCategoryMap.h:37
lldb_private::TypeCategoryMap::ActiveCategoriesList
std::list< lldb::TypeCategoryImplSP > ActiveCategoriesList
Definition: TypeCategoryMap.h:29
lldb_private::TypeCategoryMap::MapType
std::map< KeyType, ValueSP > MapType
Definition: TypeCategoryMap.h:33
lldb_private::TypeCategoryMap::m_map
MapType m_map
Definition: TypeCategoryMap.h:98
lldb_private::TypeCategoryImpl::SharedPointer
std::shared_ptr< TypeCategoryImpl > SharedPointer
Definition: TypeCategory.h:316
lldb_private::TypeCategoryMap::Delete
bool Delete(KeyType name)
Definition: TypeCategoryMap.cpp:34
lldb_private::TypeCategoryMap::DisableAllCategories
void DisableAllCategories()
Definition: TypeCategoryMap.cpp:117
uint32_t
lldb_private::TypeCategoryMap::ValueType
TypeCategoryImpl ValueType
Definition: TypeCategoryMap.h:27
lldb_private::TypeCategoryMap::Disable
bool Disable(KeyType category_name)
Definition: TypeCategoryMap.cpp:54
lldb_private::TypeCategoryMap::Add
void Add(KeyType name, const ValueSP &entry)
Definition: TypeCategoryMap.cpp:27
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
uint16_t
lldb_private::TypeCategoryMap::listener
IFormatChangeListener * listener
Definition: TypeCategoryMap.h:96
lldb_private::TypeCategoryMap::ForEach
void ForEach(ForEachCallback callback)
Definition: TypeCategoryMap.cpp:220
TypeCategory.h
lldb_private::TypeCategoryMap::m_active_categories
ActiveCategoriesList m_active_categories
Definition: TypeCategoryMap.h:99
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::TypeCategoryMap::Get
bool Get(KeyType name, ValueSP &entry)
Definition: TypeCategoryMap.cpp:133
lldb_private::TypeCategoryMap::Clear
void Clear()
Definition: TypeCategoryMap.cpp:125
lldb_private::TypeCategoryMap::Last
static const Position Last
Definition: TypeCategoryMap.h:41
lldb_private::TypeCategoryMap::m_map_mutex
std::recursive_mutex m_map_mutex
Definition: TypeCategoryMap.h:95
lldb_private::TypeCategoryMap::delete_matching_categories::ptr
lldb::TypeCategoryImplSP ptr
Definition: TypeCategoryMap.h:84
lldb_private::TypeCategoryImpl
Definition: TypeCategory.h:63
lldb_private::TypeCategoryMap::delete_matching_categories::delete_matching_categories
delete_matching_categories(lldb::TypeCategoryImplSP p)
Definition: TypeCategoryMap.h:87
lldb_private::TypeCategoryMap::GetCount
uint32_t GetCount()
Definition: TypeCategoryMap.h:78
FormattersContainer.h
lldb_private::IFormatChangeListener
Definition: FormattersContainer.h:31
lldb_private::TypeCategoryMap::KeyType
ConstString KeyType
Definition: TypeCategoryMap.h:26