]> src.bluestatic.org Git - macgdbp.git/blob - Source/ProtocolClient.h
Call -[NSInvocation retainArguments] in ThreadSafeDelegate.
[macgdbp.git] / Source / ProtocolClient.h
1 /*
2 * MacGDBp
3 * Copyright (c) 2013, Blue Static <http://www.bluestatic.org>
4 *
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17 #import <Foundation/Foundation.h>
18
19 #import "MessageQueue.h"
20
21 @protocol ProtocolClientDelegate;
22
23 // ProtocolClient sends string commands to a DBGP <http://www.xdebug.org/docs-dbgp.php>
24 // debugger engine and receives XML packets in response. This class ensures
25 // proper sequencing of the messages.
26 @interface ProtocolClient : NSObject<MessageQueueDelegate> {
27 //@private
28 MessageQueue* _messageQueue;
29
30 NSRecursiveLock* _lock;
31 NSInteger _nextID;
32
33 NSInteger _lastReadID;
34 NSInteger _lastWrittenID;
35
36 NSObject<ProtocolClientDelegate>* _delegate;
37 NSThread* _delegateThread;
38 }
39
40 - (id)initWithDelegate:(NSObject<ProtocolClientDelegate>*)delegate;
41
42 - (BOOL)isConnected;
43
44 - (void)connectOnPort:(NSUInteger)port;
45 - (void)disconnect;
46
47 // This sends the given command format to the debugger. This method is thread
48 // safe and schedules the request on the |runLoop_|.
49 - (NSNumber*)sendCommandWithFormat:(NSString*)format, ...;
50
51 // Sends a command to the debugger. The command must have a substring |{txn}|
52 // within it, which will be replaced with the transaction ID. Use this if
53 // |-sendCommandWithFormat:|'s insertion of the transaction ID is incorrect.
54 - (NSNumber*)sendCustomCommandWithFormat:(NSString*)format, ...;
55
56 - (NSInteger)transactionIDFromResponse:(NSXMLDocument*)response;
57 - (NSInteger)transactionIDFromCommand:(NSString*)command;
58
59 @end
60
61 // Delegate ////////////////////////////////////////////////////////////////////
62
63 // All methods of the protocol client are dispatched to the thread on which the
64 // ProtocolClient was created.
65 @protocol ProtocolClientDelegate
66 - (void)debuggerEngineConnected:(ProtocolClient*)client;
67 - (void)debuggerEngineDisconnected:(ProtocolClient*)client;
68
69 - (void)debuggerEngine:(ProtocolClient*)client receivedMessage:(NSXMLDocument*)message;
70 @end