1a5ea1e2bSKuba Brecka //===-- SBThreadCollection.cpp ----------------------------------*- C++ -*-===// 2a5ea1e2bSKuba Brecka // 3a5ea1e2bSKuba Brecka // The LLVM Compiler Infrastructure 4a5ea1e2bSKuba Brecka // 5a5ea1e2bSKuba Brecka // This file is distributed under the University of Illinois Open Source 6a5ea1e2bSKuba Brecka // License. See LICENSE.TXT for details. 7a5ea1e2bSKuba Brecka // 8a5ea1e2bSKuba Brecka //===----------------------------------------------------------------------===// 9a5ea1e2bSKuba Brecka 10a5ea1e2bSKuba Brecka #include "lldb/API/SBThreadCollection.h" 11a5ea1e2bSKuba Brecka #include "lldb/API/SBThread.h" 12a5ea1e2bSKuba Brecka #include "lldb/Target/ThreadList.h" 13a5ea1e2bSKuba Brecka 14a5ea1e2bSKuba Brecka using namespace lldb; 15a5ea1e2bSKuba Brecka using namespace lldb_private; 16a5ea1e2bSKuba Brecka 17*b9c1b51eSKate Stone SBThreadCollection::SBThreadCollection() : m_opaque_sp() {} 18a5ea1e2bSKuba Brecka 19*b9c1b51eSKate Stone SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs) 20*b9c1b51eSKate Stone : m_opaque_sp(rhs.m_opaque_sp) {} 21a5ea1e2bSKuba Brecka 22*b9c1b51eSKate Stone const SBThreadCollection &SBThreadCollection:: 23*b9c1b51eSKate Stone operator=(const SBThreadCollection &rhs) { 24a5ea1e2bSKuba Brecka if (this != &rhs) 25a5ea1e2bSKuba Brecka m_opaque_sp = rhs.m_opaque_sp; 26a5ea1e2bSKuba Brecka return *this; 27a5ea1e2bSKuba Brecka } 28a5ea1e2bSKuba Brecka 29*b9c1b51eSKate Stone SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) 30*b9c1b51eSKate Stone : m_opaque_sp(threads) {} 31a5ea1e2bSKuba Brecka 32*b9c1b51eSKate Stone SBThreadCollection::~SBThreadCollection() {} 33a5ea1e2bSKuba Brecka 34*b9c1b51eSKate Stone void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) { 35a5ea1e2bSKuba Brecka m_opaque_sp = threads; 36a5ea1e2bSKuba Brecka } 37a5ea1e2bSKuba Brecka 38*b9c1b51eSKate Stone lldb_private::ThreadCollection *SBThreadCollection::get() const { 39a5ea1e2bSKuba Brecka return m_opaque_sp.get(); 40a5ea1e2bSKuba Brecka } 41a5ea1e2bSKuba Brecka 42*b9c1b51eSKate Stone lldb_private::ThreadCollection *SBThreadCollection::operator->() const { 43a5ea1e2bSKuba Brecka return m_opaque_sp.operator->(); 44a5ea1e2bSKuba Brecka } 45a5ea1e2bSKuba Brecka 46*b9c1b51eSKate Stone lldb::ThreadCollectionSP &SBThreadCollection::operator*() { 47a5ea1e2bSKuba Brecka return m_opaque_sp; 48a5ea1e2bSKuba Brecka } 49a5ea1e2bSKuba Brecka 50*b9c1b51eSKate Stone const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const { 51a5ea1e2bSKuba Brecka return m_opaque_sp; 52a5ea1e2bSKuba Brecka } 53a5ea1e2bSKuba Brecka 54*b9c1b51eSKate Stone bool SBThreadCollection::IsValid() const { return m_opaque_sp.get() != NULL; } 55a5ea1e2bSKuba Brecka 56*b9c1b51eSKate Stone size_t SBThreadCollection::GetSize() { 57a5ea1e2bSKuba Brecka if (m_opaque_sp) 58a5ea1e2bSKuba Brecka return m_opaque_sp->GetSize(); 59a5ea1e2bSKuba Brecka return 0; 60a5ea1e2bSKuba Brecka } 61a5ea1e2bSKuba Brecka 62*b9c1b51eSKate Stone SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) { 63a5ea1e2bSKuba Brecka SBThread thread; 64a5ea1e2bSKuba Brecka if (m_opaque_sp && idx < m_opaque_sp->GetSize()) 65a5ea1e2bSKuba Brecka thread = m_opaque_sp->GetThreadAtIndex(idx); 66a5ea1e2bSKuba Brecka return thread; 67a5ea1e2bSKuba Brecka } 68