diff options
author | Melanie Thielker | 2008-09-26 15:34:23 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-09-26 15:34:23 +0000 |
commit | 12a6b7c835cae71e87352a48087c253e8c147c38 (patch) | |
tree | 52b9d26b7cb62e0b1ae1a6a6f5db42dabe511899 /OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs | |
parent | * minor: fix lolbug in RestInventoryService spotted by jhurliman (diff) | |
download | opensim-SC-12a6b7c835cae71e87352a48087c253e8c147c38.zip opensim-SC-12a6b7c835cae71e87352a48087c253e8c147c38.tar.gz opensim-SC-12a6b7c835cae71e87352a48087c253e8c147c38.tar.bz2 opensim-SC-12a6b7c835cae71e87352a48087c253e8c147c38.tar.xz |
Yay! Common/ is gone! One API is achieved!
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs | 213 |
1 files changed, 0 insertions, 213 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs deleted file mode 100644 index eba88f3..0000000 --- a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs +++ /dev/null | |||
@@ -1,213 +0,0 @@ | |||
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 OpenSim 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.Generic; | ||
30 | using System.Runtime.Remoting.Lifetime; | ||
31 | |||
32 | namespace OpenSim.Region.ScriptEngine.Common | ||
33 | { | ||
34 | public abstract class ExecutorBase : MarshalByRefObject | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Contains the script to execute functions in. | ||
38 | /// </summary> | ||
39 | protected IScript m_Script; | ||
40 | /// <summary> | ||
41 | /// If set to False events will not be executed. | ||
42 | /// </summary> | ||
43 | protected bool m_Running = true; | ||
44 | /// <summary> | ||
45 | /// True indicates that the ScriptManager has stopped | ||
46 | /// this script. This prevents a script that has been | ||
47 | /// stopped as part of deactivation from being | ||
48 | /// resumed by a pending llSetScriptState request. | ||
49 | /// </summary> | ||
50 | protected bool m_Disable = false; | ||
51 | |||
52 | /// <summary> | ||
53 | /// Indicate the scripts current running status. | ||
54 | /// </summary> | ||
55 | public bool Running | ||
56 | { | ||
57 | get { return m_Running; } | ||
58 | set | ||
59 | { | ||
60 | if (!m_Disable) | ||
61 | m_Running = value; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | protected Dictionary<string, scriptEvents> m_eventFlagsMap = new Dictionary<string, scriptEvents>(); | ||
66 | |||
67 | [Flags] | ||
68 | public enum scriptEvents : int | ||
69 | { | ||
70 | None = 0, | ||
71 | attach = 1, | ||
72 | collision = 16, | ||
73 | collision_end = 32, | ||
74 | collision_start = 64, | ||
75 | control = 128, | ||
76 | dataserver = 256, | ||
77 | email = 512, | ||
78 | http_response = 1024, | ||
79 | land_collision = 2048, | ||
80 | land_collision_end = 4096, | ||
81 | land_collision_start = 8192, | ||
82 | at_target = 16384, | ||
83 | listen = 32768, | ||
84 | money = 65536, | ||
85 | moving_end = 131072, | ||
86 | moving_start = 262144, | ||
87 | not_at_rot_target = 524288, | ||
88 | not_at_target = 1048576, | ||
89 | remote_data = 8388608, | ||
90 | run_time_permissions = 268435456, | ||
91 | state_entry = 1073741824, | ||
92 | state_exit = 2, | ||
93 | timer = 4, | ||
94 | touch = 8, | ||
95 | touch_end = 536870912, | ||
96 | touch_start = 2097152, | ||
97 | object_rez = 4194304 | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Create a new instance of ExecutorBase | ||
102 | /// </summary> | ||
103 | /// <param name="Script"></param> | ||
104 | public ExecutorBase(IScript Script) | ||
105 | { | ||
106 | m_Script = Script; | ||
107 | initEventFlags(); | ||
108 | } | ||
109 | |||
110 | /// <summary> | ||
111 | /// Make sure our object does not timeout when in AppDomain. (Called by ILease base class) | ||
112 | /// </summary> | ||
113 | /// <returns></returns> | ||
114 | public override Object InitializeLifetimeService() | ||
115 | { | ||
116 | //Console.WriteLine("Executor: InitializeLifetimeService()"); | ||
117 | // return null; | ||
118 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
119 | |||
120 | if (lease.CurrentState == LeaseState.Initial) | ||
121 | { | ||
122 | lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); | ||
123 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); | ||
124 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
125 | } | ||
126 | return lease; | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// Get current AppDomain | ||
131 | /// </summary> | ||
132 | /// <returns>Current AppDomain</returns> | ||
133 | public AppDomain GetAppDomain() | ||
134 | { | ||
135 | return AppDomain.CurrentDomain; | ||
136 | } | ||
137 | |||
138 | /// <summary> | ||
139 | /// Execute a specific function/event in script. | ||
140 | /// </summary> | ||
141 | /// <param name="FunctionName">Name of function to execute</param> | ||
142 | /// <param name="args">Arguments to pass to function</param> | ||
143 | public void ExecuteEvent(string state, string FunctionName, object[] args) | ||
144 | { | ||
145 | DoExecuteEvent(state, FunctionName, args); | ||
146 | } | ||
147 | |||
148 | protected abstract void DoExecuteEvent(string state, string FunctionName, object[] args); | ||
149 | |||
150 | /// <summary> | ||
151 | /// Compute the events handled by the current state of the script | ||
152 | /// </summary> | ||
153 | /// <returns>state mask</returns> | ||
154 | public scriptEvents GetStateEventFlags(string state) | ||
155 | { | ||
156 | return DoGetStateEventFlags(state); | ||
157 | } | ||
158 | |||
159 | protected abstract scriptEvents DoGetStateEventFlags(string state); | ||
160 | |||
161 | /// <summary> | ||
162 | /// Stop script from running. Event execution will be ignored. | ||
163 | /// </summary> | ||
164 | public void StopScript() | ||
165 | { | ||
166 | m_Running = false; | ||
167 | m_Disable = true; | ||
168 | } | ||
169 | |||
170 | protected void initEventFlags() | ||
171 | { | ||
172 | // Initialize the table if it hasn't already been done | ||
173 | if (m_eventFlagsMap.Count > 0) | ||
174 | { | ||
175 | return; | ||
176 | } | ||
177 | |||
178 | m_eventFlagsMap.Add("attach", scriptEvents.attach); | ||
179 | // m_eventFlagsMap.Add("at_rot_target",(long)scriptEvents.at_rot_target); | ||
180 | m_eventFlagsMap.Add("at_target", scriptEvents.at_target); | ||
181 | // m_eventFlagsMap.Add("changed",(long)scriptEvents.changed); | ||
182 | m_eventFlagsMap.Add("collision", scriptEvents.collision); | ||
183 | m_eventFlagsMap.Add("collision_end", scriptEvents.collision_end); | ||
184 | m_eventFlagsMap.Add("collision_start", scriptEvents.collision_start); | ||
185 | m_eventFlagsMap.Add("control", scriptEvents.control); | ||
186 | m_eventFlagsMap.Add("dataserver", scriptEvents.dataserver); | ||
187 | m_eventFlagsMap.Add("email", scriptEvents.email); | ||
188 | m_eventFlagsMap.Add("http_response", scriptEvents.http_response); | ||
189 | m_eventFlagsMap.Add("land_collision", scriptEvents.land_collision); | ||
190 | m_eventFlagsMap.Add("land_collision_end", scriptEvents.land_collision_end); | ||
191 | m_eventFlagsMap.Add("land_collision_start", scriptEvents.land_collision_start); | ||
192 | // m_eventFlagsMap.Add("link_message",scriptEvents.link_message); | ||
193 | m_eventFlagsMap.Add("listen", scriptEvents.listen); | ||
194 | m_eventFlagsMap.Add("money", scriptEvents.money); | ||
195 | m_eventFlagsMap.Add("moving_end", scriptEvents.moving_end); | ||
196 | m_eventFlagsMap.Add("moving_start", scriptEvents.moving_start); | ||
197 | m_eventFlagsMap.Add("not_at_rot_target", scriptEvents.not_at_rot_target); | ||
198 | m_eventFlagsMap.Add("not_at_target", scriptEvents.not_at_target); | ||
199 | // m_eventFlagsMap.Add("no_sensor",(long)scriptEvents.no_sensor); | ||
200 | // m_eventFlagsMap.Add("on_rez",(long)scriptEvents.on_rez); | ||
201 | m_eventFlagsMap.Add("remote_data", scriptEvents.remote_data); | ||
202 | m_eventFlagsMap.Add("run_time_permissions", scriptEvents.run_time_permissions); | ||
203 | // m_eventFlagsMap.Add("sensor",(long)scriptEvents.sensor); | ||
204 | m_eventFlagsMap.Add("state_entry", scriptEvents.state_entry); | ||
205 | m_eventFlagsMap.Add("state_exit", scriptEvents.state_exit); | ||
206 | m_eventFlagsMap.Add("timer", scriptEvents.timer); | ||
207 | m_eventFlagsMap.Add("touch", scriptEvents.touch); | ||
208 | m_eventFlagsMap.Add("touch_end", scriptEvents.touch_end); | ||
209 | m_eventFlagsMap.Add("touch_start", scriptEvents.touch_start); | ||
210 | m_eventFlagsMap.Add("object_rez", scriptEvents.object_rez); | ||
211 | } | ||
212 | } | ||
213 | } | ||