Sub Process_Globals
Private mCallBack As Object
Private mEventName As String
Private mEngine As Map
End Sub
' I know an Initialize is not needed for Code Module, but I leave it here for consistency
Public Sub Initialize(CallBack As Object, EventName As String)
mCallBack = CallBack
mEventName = EventName
Engine.Initialize
Engine.Put("manager", Me)
CallSub(mCallBack, mEventName & "_Initialized")
End Sub
Public Sub Engine As Map
Return mEngine
End Sub
Public Sub startEngine(EngineType As Int)
Select EngineType
Case Utils.ENGINE_A
Dim EngineA As EngineAClass
EngineA.Initialize(Me, "Engine")
Engine.Put("type", Utils.ENGINE_A)
Engine.Put("core", EngineA)
Case Utils.ENGINE_B
Dim EngineB As EngineBClass
EngineB.Initialize(Me, "Engine")
Engine.Put("type", Utils.ENGINE_B)
Engine.Put("core", EngineB)
' [...] more engines...
End Select
CallSub(mCallBack, mEventName & "_EngineStarted")
End Sub
Private Sub run(cmd As String, Args() As Object) As Object
Dim NumberOfParameters As Int
If (Args = Null) Then
NumberOfParameters = 0
Else
NumberOfParameters = Min(Args.Length, 2)
End If
cmd = "Do_" & cmd
Select NumberOfParameters
Case 0
Return CallSub(Engine.Get("core"), cmd)
Case 1
Return CallSub2(Engine.Get("core"), cmd, Args(0))
Case 2
Return CallSub3(Engine.Get("core"), cmd, Args(0), Args(1))
End Select
Return Me ' I'd love to throw an exception here... but I can't find a way to do it. HELP!
End Sub