xref: /llvm-project/lldb/source/API/SBThreadCollection.cpp (revision 2946cd701067404b99c39fb29dc9c74bd7193eb3)
1 //===-- SBThreadCollection.cpp ----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/API/SBThreadCollection.h"
10 #include "lldb/API/SBThread.h"
11 #include "lldb/Target/ThreadList.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
16 SBThreadCollection::SBThreadCollection() : m_opaque_sp() {}
17 
18 SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs)
19     : m_opaque_sp(rhs.m_opaque_sp) {}
20 
21 const SBThreadCollection &SBThreadCollection::
22 operator=(const SBThreadCollection &rhs) {
23   if (this != &rhs)
24     m_opaque_sp = rhs.m_opaque_sp;
25   return *this;
26 }
27 
28 SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads)
29     : m_opaque_sp(threads) {}
30 
31 SBThreadCollection::~SBThreadCollection() {}
32 
33 void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) {
34   m_opaque_sp = threads;
35 }
36 
37 lldb_private::ThreadCollection *SBThreadCollection::get() const {
38   return m_opaque_sp.get();
39 }
40 
41 lldb_private::ThreadCollection *SBThreadCollection::operator->() const {
42   return m_opaque_sp.operator->();
43 }
44 
45 lldb::ThreadCollectionSP &SBThreadCollection::operator*() {
46   return m_opaque_sp;
47 }
48 
49 const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const {
50   return m_opaque_sp;
51 }
52 
53 bool SBThreadCollection::IsValid() const { return m_opaque_sp.get() != NULL; }
54 
55 size_t SBThreadCollection::GetSize() {
56   if (m_opaque_sp)
57     return m_opaque_sp->GetSize();
58   return 0;
59 }
60 
61 SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) {
62   SBThread thread;
63   if (m_opaque_sp && idx < m_opaque_sp->GetSize())
64     thread = m_opaque_sp->GetThreadAtIndex(idx);
65   return thread;
66 }
67