1996-03-19 02:02:52 +00:00
|
|
|
|
/* Interface for NSRunLoop for GNUStep
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1996-03-19 02:02:52 +00:00
|
|
|
|
Created: March 1996
|
|
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
|
This file is part of the GNUstep Base Library.
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
|
License along with this library; if not, write to the Free
|
2005-05-22 03:32:16 +00:00
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
1996-03-19 02:02:52 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
|
#ifndef __NSRunLoop_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
#define __NSRunLoop_h_GNUSTEP_BASE_INCLUDE
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
#include <Foundation/NSMapTable.h>
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@class NSTimer, NSDate, NSPort;
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
2004-07-29 15:30:47 +00:00
|
|
|
|
/**
|
|
|
|
|
* Run loop mode used to deal with input sources other than NSConnections or
|
|
|
|
|
* dialog windows. Most commonly used. Defined in
|
|
|
|
|
* <code>Foundation/NSRunLoop.h</code>.
|
|
|
|
|
*/
|
2002-06-06 14:02:59 +00:00
|
|
|
|
GS_EXPORT NSString * const NSDefaultRunLoopMode;
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
|
@interface NSRunLoop : NSObject <GCFinalization>
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
1999-04-19 14:29:52 +00:00
|
|
|
|
@private
|
2002-01-30 15:28:50 +00:00
|
|
|
|
NSString *_currentMode;
|
|
|
|
|
NSMapTable *_contextMap;
|
|
|
|
|
NSMutableArray *_contextStack;
|
|
|
|
|
NSMutableArray *_timedPerformers;
|
|
|
|
|
void *_extra;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
|
|
+ (NSRunLoop*) currentRunLoop;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
- (void) acceptInputForMode: (NSString*)mode
|
2001-12-17 14:31:42 +00:00
|
|
|
|
beforeDate: (NSDate*)limit_date;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
- (void) addTimer: (NSTimer*)timer
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
|
1996-03-19 02:02:52 +00:00
|
|
|
|
- (NSString*) currentMode;
|
|
|
|
|
|
2002-01-30 15:28:50 +00:00
|
|
|
|
- (NSDate*) limitDateForMode: (NSString*)mode;
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
|
|
- (void) run;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
- (BOOL) runMode: (NSString*)mode
|
|
|
|
|
beforeDate: (NSDate*)date;
|
|
|
|
|
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (void) runUntilDate: (NSDate*)date;
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@interface NSRunLoop(OPENSTEP)
|
|
|
|
|
|
|
|
|
|
- (void) addPort: (NSPort*)port
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
|
2002-08-27 14:24:54 +00:00
|
|
|
|
- (void) cancelPerformSelectorsWithTarget: (id)target;
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
- (void) cancelPerformSelector: (SEL)aSelector
|
2002-01-30 15:28:50 +00:00
|
|
|
|
target: (id)target
|
|
|
|
|
argument: (id)argument;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
- (void) configureAsServer;
|
|
|
|
|
|
|
|
|
|
- (void) performSelector: (SEL)aSelector
|
2002-01-30 15:28:50 +00:00
|
|
|
|
target: (id)target
|
|
|
|
|
argument: (id)argument
|
1997-09-01 21:59:51 +00:00
|
|
|
|
order: (unsigned int)order
|
|
|
|
|
modes: (NSArray*)modes;
|
|
|
|
|
|
|
|
|
|
- (void) removePort: (NSPort*)port
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
|
|
|
|
|
@end
|
1996-04-10 18:21:12 +00:00
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* GNUstep extensions
|
1996-04-10 18:21:12 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2004-07-29 15:30:47 +00:00
|
|
|
|
/**
|
2004-08-02 18:10:58 +00:00
|
|
|
|
* Enumeration of event types that an [NSRunLoop] watcher
|
2004-07-29 15:30:47 +00:00
|
|
|
|
* can watch for. See [NSRunLoop-addEvent:type:watcher:forMode:].
|
2004-08-02 18:10:58 +00:00
|
|
|
|
* This is a GNUstep extension.
|
2004-07-29 15:30:47 +00:00
|
|
|
|
<example>
|
|
|
|
|
{
|
|
|
|
|
ET_RDESC, // Watch for descriptor becoming readable.
|
|
|
|
|
ET_WDESC, // Watch for descriptor becoming writeable.
|
|
|
|
|
ET_RPORT, // Watch for message arriving on port.
|
|
|
|
|
ET_EDESC // Watch for descriptor with out-of-band data.
|
|
|
|
|
}
|
|
|
|
|
</example>
|
|
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
|
typedef enum {
|
2005-02-23 16:05:09 +00:00
|
|
|
|
#ifdef __MINGW__
|
|
|
|
|
ET_HANDLE,
|
2005-07-23 13:43:31 +00:00
|
|
|
|
ET_RPORT /* Watch for message arriving on port. */
|
2005-02-23 16:05:09 +00:00
|
|
|
|
#else
|
2002-01-30 15:28:50 +00:00
|
|
|
|
ET_RDESC, /* Watch for descriptor becoming readable. */
|
|
|
|
|
ET_WDESC, /* Watch for descriptor becoming writeable. */
|
2005-03-07 01:11:38 +00:00
|
|
|
|
ET_RPORT, /* Watch for message arriving on port. */
|
|
|
|
|
ET_EDESC /* Watch for descriptor with out-of-band data. */
|
|
|
|
|
#endif
|
1997-09-01 21:59:51 +00:00
|
|
|
|
} RunLoopEventType;
|
|
|
|
|
|
2004-03-28 11:13:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* This protocol documents the callback messages that an object
|
|
|
|
|
* receives if it has registered to receive run loop events using
|
|
|
|
|
* [NSRunLoop-addEvent:type:watcher:forMode:]
|
|
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@protocol RunLoopEvents
|
2004-03-28 11:13:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* Callback message sent to object waiting for an event in the
|
|
|
|
|
* runloop when the limit-date for the operation is reached.
|
|
|
|
|
* If an NSDate object is returned, the operation is restarted
|
|
|
|
|
* with the new limit-date, otherwise it is removed from the
|
|
|
|
|
* run loop.
|
1997-09-01 21:59:51 +00:00
|
|
|
|
*/
|
|
|
|
|
- (NSDate*) timedOutEvent: (void*)data
|
|
|
|
|
type: (RunLoopEventType)type
|
|
|
|
|
forMode: (NSString*)mode;
|
2004-03-28 11:13:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* Callback message sent to object when the event it it waiting
|
|
|
|
|
* for occurs. The 'data' and 'type' valueds are those passed in the
|
2004-07-29 15:30:47 +00:00
|
|
|
|
* original -addEvent:type:watcher:forMode: method.
|
2004-03-28 11:13:36 +00:00
|
|
|
|
* The 'extra' value may be additional data returned depending
|
|
|
|
|
* on the type of event.
|
1997-09-01 21:59:51 +00:00
|
|
|
|
*/
|
|
|
|
|
- (void) receivedEvent: (void*)data
|
|
|
|
|
type: (RunLoopEventType)type
|
|
|
|
|
extra: (void*)extra
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
@end
|
|
|
|
|
|
2004-03-28 11:13:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* These are general purpose methods for letting objects ask
|
|
|
|
|
* the runloop to watch for events for them. Only one object
|
|
|
|
|
* at a time may be watching for a particular event in a mode, but
|
2004-06-22 22:27:39 +00:00
|
|
|
|
* that object may add itself as a watcher many times as long as
|
2004-03-28 11:13:36 +00:00
|
|
|
|
* each addition is matched by a removal (the run loop keeps count).
|
|
|
|
|
* Alternatively, the 'removeAll' parameter may be set to 'YES' for
|
|
|
|
|
* [-removeEvent:type:forMode:all:] in order to remove the watcher
|
|
|
|
|
* irrespective of the number of times it has been added.
|
|
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@interface NSRunLoop(GNUstepExtensions)
|
|
|
|
|
|
2004-03-28 11:13:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* Adds a runloop watcher matching the specified data and type in this
|
|
|
|
|
* runloop. If the mode is nil, either the -currentMode is used (if the
|
|
|
|
|
* loop is running) or NSDefaultRunLoopMode is used.<br />
|
|
|
|
|
* NB. The watcher is <em>not</em> retained by the run loop and must
|
|
|
|
|
* be removed from the loop before deallocation ... otherwise the loop
|
|
|
|
|
* might try to send a message to the deallocated watcher object
|
|
|
|
|
* resulting in a crash. You use -removeEvent:type:forMode:all: to do this.
|
1997-09-01 21:59:51 +00:00
|
|
|
|
*/
|
|
|
|
|
- (void) addEvent: (void*)data
|
|
|
|
|
type: (RunLoopEventType)type
|
|
|
|
|
watcher: (id<RunLoopEvents>)watcher
|
|
|
|
|
forMode: (NSString*)mode;
|
2004-03-28 11:13:36 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes a runloop watcher matching the specified data and type in this
|
|
|
|
|
* runloop. If the mode is nil, either the -currentMode is used (if the
|
|
|
|
|
* loop is running) or NSDefaultRunLoopMode is used.<br />
|
|
|
|
|
* The additional removeAll flag may be used to remove all instances of
|
|
|
|
|
* the watcher rather than just a single one.
|
|
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
|
- (void) removeEvent: (void*)data
|
|
|
|
|
type: (RunLoopEventType)type
|
1997-09-09 15:30:24 +00:00
|
|
|
|
forMode: (NSString*)mode
|
|
|
|
|
all: (BOOL)removeAll;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* Defines implementation-helper method -getFds:count:.
|
|
|
|
|
* <strong>This interface will probably change. Do not rely on it.</strong>
|
|
|
|
|
*/
|
|
|
|
|
// xxx This interface will probably change.
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@interface NSObject (OptionalPortRunLoop)
|
2004-06-22 22:27:39 +00:00
|
|
|
|
/** If a InPort object responds to this, it is sent just before we are
|
1997-09-01 21:59:51 +00:00
|
|
|
|
about to wait listening for input.
|
|
|
|
|
This interface will probably change. */
|
|
|
|
|
- (void) getFds: (int*)fds count: (int*)count;
|
|
|
|
|
@end
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
2005-02-23 16:05:09 +00:00
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
|
/**
|
|
|
|
|
* Interface that add method to set target for win32 messages.<br />
|
|
|
|
|
*/
|
|
|
|
|
@interface NSRunLoop(mingw32)
|
|
|
|
|
/**
|
|
|
|
|
* Adds a target to the loop in the specified mode for the
|
|
|
|
|
* win32 messages.<br />
|
|
|
|
|
* Only a target+selector is added in one mode. Successive
|
|
|
|
|
* calls overwrite the previous.<br />
|
|
|
|
|
*/
|
|
|
|
|
- (void) addMsgTarget: (id)target
|
|
|
|
|
withMethod: (SEL)selector
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
/**
|
|
|
|
|
* Delete the target of the loop in the specified mode for the
|
|
|
|
|
* win32 messages.<br />
|
|
|
|
|
*/
|
|
|
|
|
- (void) removeMsgForMode: (NSString*)mode;
|
|
|
|
|
@end
|
|
|
|
|
#endif
|
1996-04-17 19:36:35 +00:00
|
|
|
|
#endif /*__NSRunLoop_h_GNUSTEP_BASE_INCLUDE */
|