Home | History | Annotate | Download | only in DataFormatters
      1 //===-- TypeCategory.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_TypeCategory_h_
     11 #define lldb_TypeCategory_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 
     23 namespace lldb_private {
     24     class TypeCategoryImpl
     25     {
     26     private:
     27 
     28         typedef FormatNavigator<ConstString, TypeSummaryImpl> SummaryNavigator;
     29         typedef FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl> RegexSummaryNavigator;
     30 
     31         typedef FormatNavigator<ConstString, TypeFilterImpl> FilterNavigator;
     32         typedef FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl> RegexFilterNavigator;
     33 
     34 #ifndef LLDB_DISABLE_PYTHON
     35         typedef FormatNavigator<ConstString, ScriptedSyntheticChildren> SynthNavigator;
     36         typedef FormatNavigator<lldb::RegularExpressionSP, ScriptedSyntheticChildren> RegexSynthNavigator;
     37 #endif // #ifndef LLDB_DISABLE_PYTHON
     38 
     39         typedef SummaryNavigator::MapType SummaryMap;
     40         typedef RegexSummaryNavigator::MapType RegexSummaryMap;
     41         typedef FilterNavigator::MapType FilterMap;
     42         typedef RegexFilterNavigator::MapType RegexFilterMap;
     43 #ifndef LLDB_DISABLE_PYTHON
     44         typedef SynthNavigator::MapType SynthMap;
     45         typedef RegexSynthNavigator::MapType RegexSynthMap;
     46 #endif // #ifndef LLDB_DISABLE_PYTHON
     47 
     48     public:
     49 
     50         typedef uint16_t FormatCategoryItems;
     51         static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
     52 
     53         typedef SummaryNavigator::SharedPointer SummaryNavigatorSP;
     54         typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP;
     55         typedef FilterNavigator::SharedPointer FilterNavigatorSP;
     56         typedef RegexFilterNavigator::SharedPointer RegexFilterNavigatorSP;
     57 #ifndef LLDB_DISABLE_PYTHON
     58         typedef SynthNavigator::SharedPointer SynthNavigatorSP;
     59         typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP;
     60 #endif // #ifndef LLDB_DISABLE_PYTHON
     61 
     62         TypeCategoryImpl (IFormatChangeListener* clist,
     63                           ConstString name);
     64 
     65         SummaryNavigatorSP
     66         GetSummaryNavigator ()
     67         {
     68             return SummaryNavigatorSP(m_summary_nav);
     69         }
     70 
     71         RegexSummaryNavigatorSP
     72         GetRegexSummaryNavigator ()
     73         {
     74             return RegexSummaryNavigatorSP(m_regex_summary_nav);
     75         }
     76 
     77         FilterNavigatorSP
     78         GetFilterNavigator ()
     79         {
     80             return FilterNavigatorSP(m_filter_nav);
     81         }
     82 
     83         RegexFilterNavigatorSP
     84         GetRegexFilterNavigator ()
     85         {
     86             return RegexFilterNavigatorSP(m_regex_filter_nav);
     87         }
     88 
     89         SummaryNavigator::MapValueType
     90         GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
     91 
     92         FilterNavigator::MapValueType
     93         GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
     94 
     95 #ifndef LLDB_DISABLE_PYTHON
     96         SynthNavigator::MapValueType
     97         GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
     98 #endif
     99 
    100         lldb::TypeNameSpecifierImplSP
    101         GetTypeNameSpecifierForSummaryAtIndex (size_t index);
    102 
    103         SummaryNavigator::MapValueType
    104         GetSummaryAtIndex (size_t index);
    105 
    106         FilterNavigator::MapValueType
    107         GetFilterAtIndex (size_t index);
    108 
    109         lldb::TypeNameSpecifierImplSP
    110         GetTypeNameSpecifierForFilterAtIndex (size_t index);
    111 
    112 #ifndef LLDB_DISABLE_PYTHON
    113         SynthNavigatorSP
    114         GetSyntheticNavigator ()
    115         {
    116             return SynthNavigatorSP(m_synth_nav);
    117         }
    118 
    119         RegexSynthNavigatorSP
    120         GetRegexSyntheticNavigator ()
    121         {
    122             return RegexSynthNavigatorSP(m_regex_synth_nav);
    123         }
    124 
    125         SynthNavigator::MapValueType
    126         GetSyntheticAtIndex (size_t index);
    127 
    128         lldb::TypeNameSpecifierImplSP
    129         GetTypeNameSpecifierForSyntheticAtIndex (size_t index);
    130 
    131 #endif // #ifndef LLDB_DISABLE_PYTHON
    132 
    133         bool
    134         IsEnabled () const
    135         {
    136             return m_enabled;
    137         }
    138 
    139         uint32_t
    140         GetEnabledPosition()
    141         {
    142             if (m_enabled == false)
    143                 return UINT32_MAX;
    144             else
    145                 return m_enabled_position;
    146         }
    147 
    148         bool
    149         Get (ValueObject& valobj,
    150              lldb::TypeSummaryImplSP& entry,
    151              lldb::DynamicValueType use_dynamic,
    152              uint32_t* reason = NULL);
    153 
    154         bool
    155         Get (ValueObject& valobj,
    156              lldb::SyntheticChildrenSP& entry,
    157              lldb::DynamicValueType use_dynamic,
    158              uint32_t* reason = NULL);
    159 
    160         void
    161         Clear (FormatCategoryItems items = ALL_ITEM_TYPES);
    162 
    163         bool
    164         Delete (ConstString name,
    165                 FormatCategoryItems items = ALL_ITEM_TYPES);
    166 
    167         uint32_t
    168         GetCount (FormatCategoryItems items = ALL_ITEM_TYPES);
    169 
    170         const char*
    171         GetName ()
    172         {
    173             return m_name.GetCString();
    174         }
    175 
    176         bool
    177         AnyMatches (ConstString type_name,
    178                     FormatCategoryItems items = ALL_ITEM_TYPES,
    179                     bool only_enabled = true,
    180                     const char** matching_category = NULL,
    181                     FormatCategoryItems* matching_type = NULL);
    182 
    183         typedef std::shared_ptr<TypeCategoryImpl> SharedPointer;
    184 
    185     private:
    186         SummaryNavigator::SharedPointer m_summary_nav;
    187         RegexSummaryNavigator::SharedPointer m_regex_summary_nav;
    188         FilterNavigator::SharedPointer m_filter_nav;
    189         RegexFilterNavigator::SharedPointer m_regex_filter_nav;
    190 #ifndef LLDB_DISABLE_PYTHON
    191         SynthNavigator::SharedPointer m_synth_nav;
    192         RegexSynthNavigator::SharedPointer m_regex_synth_nav;
    193 #endif // #ifndef LLDB_DISABLE_PYTHON
    194 
    195         bool m_enabled;
    196 
    197         IFormatChangeListener* m_change_listener;
    198 
    199         Mutex m_mutex;
    200 
    201         ConstString m_name;
    202 
    203         uint32_t m_enabled_position;
    204 
    205         void
    206         Enable (bool value, uint32_t position);
    207 
    208         void
    209         Disable ()
    210         {
    211             Enable(false, UINT32_MAX);
    212         }
    213 
    214         friend class TypeCategoryMap;
    215 
    216         friend class FormatNavigator<ConstString, TypeSummaryImpl>;
    217         friend class FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl>;
    218 
    219         friend class FormatNavigator<ConstString, TypeFilterImpl>;
    220         friend class FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl>;
    221 
    222 #ifndef LLDB_DISABLE_PYTHON
    223         friend class FormatNavigator<ConstString, ScriptedSyntheticChildren>;
    224         friend class FormatNavigator<lldb::RegularExpressionSP, ScriptedSyntheticChildren>;
    225 #endif // #ifndef LLDB_DISABLE_PYTHON
    226     };
    227 
    228 } // namespace lldb_private
    229 
    230 #endif	// lldb_TypeCategory_h_
    231