xref: /llvm-project/lldb/source/API/SBThreadCollection.cpp (revision a5ea1e2b6c60905ed39401876b8bd28a115e39ea)
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 
17 
18 SBThreadCollection::SBThreadCollection () :
19     m_opaque_sp()
20 {
21 }
22 
23 SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs) :
24     m_opaque_sp (rhs.m_opaque_sp)
25 {
26 }
27 
28 const SBThreadCollection &
29 SBThreadCollection::operator = (const SBThreadCollection &rhs)
30 {
31     if (this != &rhs)
32         m_opaque_sp = rhs.m_opaque_sp;
33     return *this;
34 }
35 
36 SBThreadCollection::SBThreadCollection (const ThreadCollectionSP &threads) :
37     m_opaque_sp(threads)
38 {
39 }
40 
41 SBThreadCollection::~SBThreadCollection ()
42 {
43 }
44 
45 void
46 SBThreadCollection::SetOpaque (const lldb::ThreadCollectionSP &threads)
47 {
48     m_opaque_sp = threads;
49 }
50 
51 lldb_private::ThreadCollection *
52 SBThreadCollection::get() const
53 {
54     return m_opaque_sp.get();
55 }
56 
57 lldb_private::ThreadCollection *
58 SBThreadCollection::operator->() const
59 {
60     return m_opaque_sp.operator->();
61 }
62 
63 lldb::ThreadCollectionSP &
64 SBThreadCollection::operator*()
65 {
66     return m_opaque_sp;
67 }
68 
69 const lldb::ThreadCollectionSP &
70 SBThreadCollection::operator*() const
71 {
72     return m_opaque_sp;
73 }
74 
75 
76 bool
77 SBThreadCollection::IsValid () const
78 {
79     return m_opaque_sp.get() != NULL;
80 }
81 
82 size_t
83 SBThreadCollection::GetSize ()
84 {
85     if (m_opaque_sp)
86         return m_opaque_sp->GetSize();
87     return 0;
88 }
89 
90 SBThread
91 SBThreadCollection::GetThreadAtIndex(size_t idx)
92 {
93     SBThread thread;
94     if (m_opaque_sp && idx < m_opaque_sp->GetSize())
95         thread = m_opaque_sp->GetThreadAtIndex(idx);
96     return thread;
97 }
98