Create a LoggingController that shows all the commands sent and received.
[macgdbp.git] / Source / LoggingController.h
1 /*
2 * MacGDBp
3 * Copyright (c) 2010, 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 <Cocoa/Cocoa.h>
18
19 @class LogEntry;
20
21 // The LoggingController manages the communication log with the debugger engine.
22 // Whenever a command or a response received, the DebuggerConnection notifies
23 // this class to record the relevant information.
24 @interface LoggingController : NSWindowController
25 {
26 // An array of log entries, with object at index 0 being the oldest entry.
27 NSMutableArray* logEntries_;
28
29 // The array controller.
30 IBOutlet NSArrayController* logEntriesController_;
31 }
32 @property (readonly) NSArray* logEntries;
33
34 // Designated initializer.
35 - (id)init;
36
37 // Creates a new log entry with the specified command, adds it to the entries
38 // list, and returns the new entry as a weak pointer. Callers can then set
39 // additional properties.
40 - (LogEntry*)recordSend:(NSString*)command;
41
42 // Creates a new log entry with the specified response data, adds it to the list
43 // of entries, and returns the new entry as a weak pointer. Callers can then set
44 // additional properties.
45 - (LogEntry*)recordReceive:(NSString*)response;
46
47 @end
48
49 // Log Entry ///////////////////////////////////////////////////////////////////
50
51 typedef enum _LogEntryDirection {
52 kLogEntrySending = 0,
53 kLogEntryReceiving
54 } LogEntryDirection;
55
56 // A simple class that stores information for a single log entry.
57 @interface LogEntry : NSObject
58 {
59 // The direction this communication went.
60 LogEntryDirection direction_;
61
62 // The command that was sent or the response.
63 NSString* contents_;
64
65 // Any error information.
66 NSError* error_;
67
68 // The values of the last read and written transaction IDs.
69 NSUInteger lastWrittenTransactionID_;
70 NSUInteger lastReadTransactionID_;
71 }
72 @property (assign) LogEntryDirection direction;
73 @property (copy) NSString* contents;
74 @property (retain) NSError* error;
75 @property (assign) NSUInteger lastWrittenTransactionID;
76 @property (assign) NSUInteger lastReadTransactionID;
77 - (NSString*)directionName;
78 @end