1 //===-- History.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_History_h_
11 #define lldb_History_h_
20 // Other libraries and framework includes
22 #include "lldb/lldb-public.h"
23 #include "lldb/Host/Mutex.h"
25 namespace lldb_private {
27 //----------------------------------------------------------------------
28 /// @class HistorySource History.h "lldb/Core/History.h"
29 /// @brief A class that defines history events.
30 //----------------------------------------------------------------------
35 typedef const void * HistoryEvent;
38 m_mutex (Mutex::eMutexTypeRecursive),
48 // Create a new history event. Subclasses should use any data or members
49 // in the subclass of this class to produce a history event and push it
50 // onto the end of the history stack.
53 CreateHistoryEvent () = 0;
56 DeleteHistoryEvent (HistoryEvent event) = 0;
59 DumpHistoryEvent (Stream &strm, HistoryEvent event) = 0;
62 GetHistoryEventCount() = 0;
65 GetHistoryEventAtIndex (uint32_t idx) = 0;
68 GetCurrentHistoryEvent () = 0;
70 // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
72 CompareHistoryEvents (const HistoryEvent lhs,
73 const HistoryEvent rhs) = 0;
76 IsCurrentHistoryEvent (const HistoryEvent event) = 0;
79 typedef std::stack<HistoryEvent> collection;
84 DISALLOW_COPY_AND_ASSIGN (HistorySource);
87 //----------------------------------------------------------------------
88 /// @class HistorySourceUInt History.h "lldb/Core/History.h"
89 /// @brief A class that defines history events that are represented by
90 /// unsigned integers.
92 /// Any history event that is defined by a unique monotonically
93 /// increasing unsigned integer
94 //----------------------------------------------------------------------
96 class HistorySourceUInt : public HistorySource
98 HistorySourceUInt (const char *id_name, uintptr_t start_value = 0u) :
101 m_curr_id (start_value)
105 ~HistorySourceUInt() override
109 // Create a new history event. Subclasses should use any data or members
110 // in the subclass of this class to produce a history event and push it
111 // onto the end of the history stack.
114 CreateHistoryEvent () override
117 return (HistoryEvent)m_curr_id;
121 DeleteHistoryEvent (HistoryEvent event) override
123 // Nothing to delete, the event contains the integer
127 DumpHistoryEvent (Stream &strm, HistoryEvent event) override;
130 GetHistoryEventCount() override
136 GetHistoryEventAtIndex (uint32_t idx) override
138 return (HistoryEvent)((uintptr_t)idx);
142 GetCurrentHistoryEvent () override
144 return (HistoryEvent)m_curr_id;
147 // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
149 CompareHistoryEvents (const HistoryEvent lhs,
150 const HistoryEvent rhs) override
152 uintptr_t lhs_uint = (uintptr_t)lhs;
153 uintptr_t rhs_uint = (uintptr_t)rhs;
154 if (lhs_uint < rhs_uint)
156 if (lhs_uint > rhs_uint)
162 IsCurrentHistoryEvent (const HistoryEvent event) override
164 return (uintptr_t)event == m_curr_id;
168 std::string m_name; // The name of the history unsigned integer
169 uintptr_t m_curr_id; // The current value of the history unsigned unteger
172 } // namespace lldb_private
174 #endif // lldb_History_h_