clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27  
28 using System;
29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Threading;
32 using OpenMetaverse;
33 using log4net;
34 using OpenSim.Framework;
35 using OpenSim.Region.Framework.Scenes;
36 using OpenSim.Region.ScriptEngine.Shared;
37 using OpenSim.Region.ScriptEngine.Interfaces;
38  
39 namespace OpenSim.Region.ScriptEngine.Interfaces
40 {
41 public enum StateSource
42 {
43 RegionStart = 0,
44 NewRez = 1,
45 PrimCrossing = 2,
46 ScriptedRez = 3,
47 AttachedRez = 4,
48 Teleporting = 5
49 }
50  
51 public interface IScriptWorkItem
52 {
53 bool Cancel();
54 bool Abort();
55  
56 /// <summary>
57 /// Wait for the work item to complete.
58 /// </summary>
59 /// <param name='t'>The number of milliseconds to wait. Must be >= -1 (Timeout.Infinite).</param>
60 bool Wait(int t);
61 }
62  
63 /// <summary>
64 /// Interface for interaction with a particular script instance
65 /// </summary>
66 public interface IScriptInstance
67 {
68 /// <summary>
69 /// Debug level for this script instance.
70 /// </summary>
71 /// <remarks>
72 /// Level == 0, no extra data is logged.
73 /// Level >= 1, state changes are logged.
74 /// Level >= 2, event firing is logged.
75 /// <value>
76 /// The debug level.
77 /// </value>
78 int DebugLevel { get; set; }
79  
80 /// <summary>
81 /// Is the script currently running?
82 /// </summary>
83 bool Running { get; set; }
84  
85 /// <summary>
86 /// Is the script suspended?
87 /// </summary>
88 bool Suspended { get; set; }
89  
90 /// <summary>
91 /// Is the script shutting down?
92 /// </summary>
93 bool ShuttingDown { get; set; }
94  
95 /// <summary>
96 /// Script state
97 /// </summary>
98 string State { get; set; }
99  
100 /// <summary>
101 /// Time the script was last started
102 /// </summary>
103 DateTime TimeStarted { get; }
104  
105 /// <summary>
106 /// Tick the last measurement period was started.
107 /// </summary>
108 long MeasurementPeriodTickStart { get; }
109  
110 /// <summary>
111 /// Ticks spent executing in the last measurement period.
112 /// </summary>
113 long MeasurementPeriodExecutionTime { get; }
114  
115 /// <summary>
116 /// Scene part in which this script instance is contained.
117 /// </summary>
118 SceneObjectPart Part { get; }
119  
120 IScriptEngine Engine { get; }
121 UUID AppDomain { get; set; }
122 string PrimName { get; }
123 string ScriptName { get; }
124 UUID ItemID { get; }
125 UUID ObjectID { get; }
126  
127 /// <summary>
128 /// UUID of the root object for the linkset that the script is in.
129 /// </summary>
130 UUID RootObjectID { get; }
131  
132 /// <summary>
133 /// Local id of the root object for the linkset that the script is in.
134 /// </summary>
135 uint RootLocalID { get; }
136  
137 uint LocalID { get; }
138 UUID AssetID { get; }
139  
140 /// <summary>
141 /// Inventory item containing the script used.
142 /// </summary>
143 TaskInventoryItem ScriptTask { get; }
144  
145 Queue EventQueue { get; }
146  
147 /// <summary>
148 /// Number of events queued for processing.
149 /// </summary>
150 long EventsQueued { get; }
151  
152 /// <summary>
153 /// Number of events processed by this script instance.
154 /// </summary>
155 long EventsProcessed { get; }
156  
157 void ClearQueue();
158 int StartParam { get; set; }
159  
160 void RemoveState();
161  
162 void Init();
163 void Start();
164  
165 /// <summary>
166 /// Stop the script instance.
167 /// </summary>
168 /// <remarks>
169 /// This must not be called by a thread that is in the process of handling an event for this script. Otherwise
170 /// there is a danger that it will self-abort and not complete the reset.
171 /// </remarks>
172 /// <param name="timeout"></param>
173 /// How many milliseconds we will wait for an existing script event to finish before
174 /// forcibly aborting that event.
175 /// <returns>true if the script was successfully stopped, false otherwise</returns>
176 bool Stop(int timeout);
177  
178 void SetState(string state);
179  
180 /// <summary>
181 /// Post an event to this script instance.
182 /// </summary>
183 /// <param name="data"></param>
184 void PostEvent(EventParams data);
185  
186 void Suspend();
187 void Resume();
188  
189 /// <summary>
190 /// Process the next event queued for this script instance.
191 /// </summary>
192 /// <returns></returns>
193 object EventProcessor();
194  
195 int EventTime();
196  
197 /// <summary>
198 /// Reset the script.
199 /// </summary>
200 /// <remarks>
201 /// This must not be called by a thread that is in the process of handling an event for this script. Otherwise
202 /// there is a danger that it will self-abort and not complete the reset. Such a thread must call
203 /// ApiResetScript() instead.
204 /// </remarks>
205 /// <param name='timeout'>
206 /// How many milliseconds we will wait for an existing script event to finish before
207 /// forcibly aborting that event prior to script reset.
208 /// </param>
209 void ResetScript(int timeout);
210  
211 /// <summary>
212 /// Reset the script.
213 /// </summary>
214 /// <remarks>
215 /// This must not be called by any thread other than the one executing the scripts current event. This is
216 /// because there is no wait or abort logic if another thread is in the middle of processing a script event.
217 /// Such an external thread should use ResetScript() instead.
218 /// </remarks>
219 void ApiResetScript();
220  
221 Dictionary<string, object> GetVars();
222 void SetVars(Dictionary<string, object> vars);
223 DetectParams GetDetectParams(int idx);
224 UUID GetDetectID(int idx);
225 void SaveState(string assembly);
226 void DestroyScriptInstance();
227  
228 IScriptApi GetApi(string name);
229  
230 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap
231 { get; set; }
232  
233 string GetAssemblyName();
234 string GetXMLState();
235 double MinEventDelay { set; }
236 UUID RegionID { get; }
237 }
238 }