1 //===-- SWIG Interface for SBCommunication ----------------------*- 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 namespace lldb {
10 
11 %feature("docstring",
12 "Allows sending/receiving data."
13 ) SBCommunication;
14 class SBCommunication
15 {
16 public:
17     enum {
18         eBroadcastBitDisconnected           = (1 << 0), ///< Sent when the communications connection is lost.
19         eBroadcastBitReadThreadGotBytes     = (1 << 1), ///< Sent by the read thread when bytes become available.
20         eBroadcastBitReadThreadDidExit      = (1 << 2), ///< Sent by the read thread when it exits to inform clients.
21         eBroadcastBitReadThreadShouldExit   = (1 << 3), ///< Sent by clients that need to cancel the read thread.
22         eBroadcastBitPacketAvailable        = (1 << 4), ///< Sent when data received makes a complete packet.
23         eAllEventBits                       = 0xffffffff
24     };
25 
26     typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len);
27 
28     SBCommunication ();
29     SBCommunication (const char * broadcaster_name);
30    ~SBCommunication ();
31 
32 
33     bool
34     IsValid () const;
35 
36     explicit operator bool() const;
37 
38     lldb::SBBroadcaster
39     GetBroadcaster ();
40 
41     static const char *GetBroadcasterClass();
42 
43     lldb::ConnectionStatus
44     AdoptFileDesriptor (int fd, bool owns_fd);
45 
46     lldb::ConnectionStatus
47     Connect (const char *url);
48 
49     lldb::ConnectionStatus
50     Disconnect ();
51 
52     bool
53     IsConnected () const;
54 
55     bool
56     GetCloseOnEOF ();
57 
58     void
59     SetCloseOnEOF (bool b);
60 
61     size_t
62     Read (void *dst,
63           size_t dst_len,
64           uint32_t timeout_usec,
65           lldb::ConnectionStatus &status);
66 
67     size_t
68     Write (const void *src,
69            size_t src_len,
70            lldb::ConnectionStatus &status);
71 
72     bool
73     ReadThreadStart ();
74 
75     bool
76     ReadThreadStop ();
77 
78     bool
79     ReadThreadIsRunning ();
80 
81     bool
82     SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback,
83                                         void *callback_baton);
84 };
85 
86 } // namespace lldb
87