1 //===-- PriorityPointerPair.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 liblldb_PriorityPointerPair_h_
11 #define liblldb_PriorityPointerPair_h_
13 #include "lldb/lldb-public.h"
14 #include "lldb/Utility/SharingPtr.h"
16 namespace lldb_utility {
18 //----------------------------------------------------------------------
19 // A prioritized pair of SharedPtr<T>. One of the two pointers is high
20 // priority, the other is low priority.
21 // The Get() method always returns high, if *high != NULL,
22 // otherwise, low is returned (even if *low == NULL)
23 //----------------------------------------------------------------------
26 class PriorityPointerPair
30 typedef T& reference_type;
31 typedef T* pointer_type;
33 typedef typename std::shared_ptr<T> T_SP;
35 PriorityPointerPair() :
40 PriorityPointerPair(pointer_type high,
46 PriorityPointerPair(pointer_type low) :
51 PriorityPointerPair(T_SP& high,
57 PriorityPointerPair(T_SP& low) :
63 SwapLow(pointer_type l)
69 SwapHigh(pointer_type h)
128 return Get().operator*();
134 return Get().operator->();
137 ~PriorityPointerPair();
144 DISALLOW_COPY_AND_ASSIGN (PriorityPointerPair);
148 } // namespace lldb_utility
150 #endif // #ifndef liblldb_PriorityPointerPair_h_