Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 1 | //===-- SBThreadCollection.cpp ----------------------------------*- 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 | #include "lldb/API/SBThreadCollection.h" |
| 11 | #include "lldb/API/SBThread.h" |
| 12 | #include "lldb/Target/ThreadList.h" |
| 13 | |
| 14 | using namespace lldb; |
| 15 | using namespace lldb_private; |
| 16 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 17 | SBThreadCollection::SBThreadCollection() : m_opaque_sp() {} |
Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 18 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 19 | SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs) |
| 20 | : m_opaque_sp(rhs.m_opaque_sp) {} |
| 21 | |
| 22 | const SBThreadCollection &SBThreadCollection:: |
| 23 | operator=(const SBThreadCollection &rhs) { |
| 24 | if (this != &rhs) |
| 25 | m_opaque_sp = rhs.m_opaque_sp; |
| 26 | return *this; |
Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 27 | } |
| 28 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 29 | SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) |
| 30 | : m_opaque_sp(threads) {} |
| 31 | |
| 32 | SBThreadCollection::~SBThreadCollection() {} |
| 33 | |
| 34 | void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) { |
| 35 | m_opaque_sp = threads; |
Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 36 | } |
| 37 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 38 | lldb_private::ThreadCollection *SBThreadCollection::get() const { |
| 39 | return m_opaque_sp.get(); |
Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 40 | } |
| 41 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 42 | lldb_private::ThreadCollection *SBThreadCollection::operator->() const { |
| 43 | return m_opaque_sp.operator->(); |
Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 44 | } |
| 45 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 46 | lldb::ThreadCollectionSP &SBThreadCollection::operator*() { |
| 47 | return m_opaque_sp; |
Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 48 | } |
| 49 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 50 | const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const { |
| 51 | return m_opaque_sp; |
Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 52 | } |
| 53 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 54 | bool SBThreadCollection::IsValid() const { return m_opaque_sp.get() != NULL; } |
| 55 | |
| 56 | size_t SBThreadCollection::GetSize() { |
| 57 | if (m_opaque_sp) |
| 58 | return m_opaque_sp->GetSize(); |
| 59 | return 0; |
Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 60 | } |
| 61 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 62 | SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) { |
| 63 | SBThread thread; |
| 64 | if (m_opaque_sp && idx < m_opaque_sp->GetSize()) |
| 65 | thread = m_opaque_sp->GetThreadAtIndex(idx); |
| 66 | return thread; |
Kuba Brecka | a5ea1e2 | 2014-09-06 01:21:19 | [diff] [blame] | 67 | } |