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);
88 //----------------------------------------------------------------------
89 /// @class HistorySourceUInt History.h "lldb/Core/History.h"
90 /// @brief A class that defines history events that are represented by
91 /// unsigned integers.
93 /// Any history event that is defined by a unique monotonically
94 /// increasing unsigned integer
95 //----------------------------------------------------------------------
97 class HistorySourceUInt : public HistorySource
99 HistorySourceUInt (const char *id_name, uintptr_t start_value = 0u) :
102 m_curr_id (start_value)
111 // Create a new history event. Subclasses should use any data or members
112 // in the subclass of this class to produce a history event and push it
113 // onto the end of the history stack.
116 CreateHistoryEvent ()
119 return (HistoryEvent)m_curr_id;
123 DeleteHistoryEvent (HistoryEvent event)
125 // Nothing to delete, the event contains the integer
129 DumpHistoryEvent (Stream &strm, HistoryEvent event);
132 GetHistoryEventCount()
138 GetHistoryEventAtIndex (uint32_t idx)
140 return (HistoryEvent)((uintptr_t)idx);
144 GetCurrentHistoryEvent ()
146 return (HistoryEvent)m_curr_id;
149 // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
151 CompareHistoryEvents (const HistoryEvent lhs,
152 const HistoryEvent rhs)
154 uintptr_t lhs_uint = (uintptr_t)lhs;
155 uintptr_t rhs_uint = (uintptr_t)rhs;
156 if (lhs_uint < rhs_uint)
158 if (lhs_uint > rhs_uint)
164 IsCurrentHistoryEvent (const HistoryEvent event)
166 return (uintptr_t)event == m_curr_id;
170 std::string m_name; // The name of the history unsigned integer
171 uintptr_t m_curr_id; // The current value of the history unsigned unteger
175 } // namespace lldb_private
177 #endif // lldb_History_h_