summaryrefslogtreecommitdiff
path: root/QSFoundation.framework/Versions/A/PrivateHeaders/NDComponentInstance.h
blob: 5e2061e5fc5812de119bea97dbf02a39396ed98c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*!
	@header NDComponentInstance
	@abstract Header file for <tt>NDComponentInstance</tt>.
	@discussion Declare the class <tt>NDComponentInstance</tt> which is used with <tt>NDAppleScriptObject</tt>
 
	Created by Nathan Day on Tue May 20 2003.
	Copyright &#169; 2002 Nathan Day. All rights reserved.
 */

#import <Cocoa/Cocoa.h>
#import "NDAppleScriptObject_Protocols.h"

/*!
	@class NDComponentInstance
	@abstract A class to represent a component instance.
	@discussion A component instance is a connection to a component (osa component) used to compile and execute AppleScripts. This class is to be used with <tt>NDAppleScriptObject</tt>.
 */
@interface NDComponentInstance : NSObject <NDAppleScriptObjectSendEvent, NDAppleScriptObjectActive>
{
@private
	ComponentInstance						scriptingComponent;
	id<NDAppleScriptObjectSendEvent>	sendAppleEventTarget;
	id<NDAppleScriptObjectActive>		activeTarget;
	OSASendUPP								defaultSendProcPtr;
	long										defaultSendProcRefCon;
	OSAActiveProcPtr						defaultActiveProcPtr;
	long										defaultActiveProcRefCon;

}

/*!
	@method sharedComponentInstance
	@abstract Returns the shared component instance.
	@discussion This is the single component all <tt>NDAppleScriptObject</tt>s use if you do not give it a <tt>NDComponentInstance</tt>. The shared component instance has a connection with the default OSA Apple component.
	@result  Returns <tt>NDComponentInstance</tt> component.
 */
+ (id)sharedComponentInstance;

/*!
	@method closeSharedComponentInstance
	@abstract Close the shared component instance.
	@discussion This can be called before you application closes or when it has finished with the shared component instance.
 */
+ (void)closeSharedComponentInstance;

/*!
	@method findNextComponent:
	@abstract Finds the next OSA component.
	@discussion Can be used by init methods that take a component parameter so that a script can be connected to it own OSA component. This is useful if you want to execute AppleScripts within separate threads as each OSA component is not thread safe.
	@result  Returns a OSA component.
 */
+ (Component)findNextComponent;

/*!
	@method componentInstance
	@abstract Allocates and initializes a <tt>NDComponentInstance</tt>
	@discussion Returns a <tt>NDComponentInstance</tt> with a connection to the default OSA Apple component.
	@result A <tt>NDComponentInstance</tt>
  */
+ (id)componentInstance;
/*!
	@method componentInstanceWithComponent:
	@abstract Allocates and initializes a <tt>NDComponentInstance</tt>
	@discussion Returns a <tt>NDComponentInstance</tt> with a connection to the supplied component.
	@param component A component, if <tt>NULL</tt> then the default AppleScript component is used..
	@result A <tt>NDComponentInstance</tt>
  */
+ (id)componentInstanceWithComponent:(Component)component;

/*!
	@method init
	@abstract Intializes a <tt>NDComponentInstance</tt>.
	@discussion The receiver opens a connection with the default AppleScript component.
	@result The initialized <tt>NDComponentInstance</tt>
	 */
- (id)init;
/*!
	@method initWithComponent:
	@abstract Intialize a <tt>NDComponentInstance</tt>.
	@discussion The receiver opens a connection with the supplied component.
	@param component A component, if <tt>NULL</tt> then the default AppleScript component is used..
	@result The initialized <tt>NDComponentInstance</tt>
  */
- (id)initWithComponent:(Component)component;

/*!
	@method setFinderAsDefaultTarget.
	@abstract  sets the default target as Finder for any AppleEvents
	@discussion passes the Finders creator code to <tt>setDefaultTargetAsCreator:</tt>.
 */
- (void)setFinderAsDefaultTarget;
	/*!
	@method setDefaultTarget:
	@abstract  sets the default target for any AppleEvents.
	@discussion any AppleEvents not enclosed in a tell statement by default go to the current
				process (your application). With this method you can provide a different default target.
	@param  defaultTarget an <tt>NSAppleEventDescriptor</tt> containing the target descriptor
 */
- (void)setDefaultTarget:(NSAppleEventDescriptor *)defaultTarget;
/*!
	@method setDefaultTargetAsCreator:
	@abstract  sets the default target, specified by creator code, for any AppleEvents
	@discussion same as setDefaultTarget: but passing the creator code of an application to specify the
				target process.
	@param creator an <tt>OSType</tt> creator code of the processes application.
 */
- (void)setDefaultTargetAsCreator:(OSType)creator;
/*!
	@method setAppleEventSendTarget:.
	@abstract  sets the object that any handles any AppleEvent the script atempts to send.
	@discussion If the send target is set any AppleEvents are sent to the send target to be processed, otherwise <tt>NDComponentInstance</tt> will handle the event itself by utilising the OSA default send procedure. One use of this is when executing a script in thread any AppleEvents that require user interaction sent to the current procees need to be sent from the main thread.
	@param  target An object that implements the protocol <tt>NDAppleScriptObjectSendEvent</tt>.
 */
- (void)setAppleEventSendTarget:(id<NDAppleScriptObjectSendEvent>)target;
/*!
	@method appleEventSendTarget
	@abstract returns the object that handles any AppleEvents
	@discussion See the method <tt>setAppleEventSendTarget: </tt>for a discussion.
	@result the AppleEvent send target.
 */
- (id<NDAppleScriptObjectSendEvent>)appleEventSendTarget;

/*!
	@method setActiveTarget:
	@abstract sets the object which is periodicly sent the message <tt>appleScriptActive:</tt>.
	@discussion will the script is running it will periodocly give up time for you to do some other processing.
	@param  target An object that implements the protocol <tt>NDAppleScriptObjectActive</tt>.
 */
- (void)setActiveTarget:(id<NDAppleScriptObjectActive>)target;

/*!
	@method activeTarget
	@abstract returns the active target as set by the method <tt>setActiveTarget:</tt>
	@discussion See the method <tt>setActiveTarget:</tt> for a discussion.
 */
- (id<NDAppleScriptObjectActive>)activeTarget;

@end