mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Starting to harmonize the new TASK logic with the old DETECTION_DISPATCHER
This commit is contained in:
@@ -127,6 +127,24 @@ function BASE:_Destructor()
|
||||
self:EventRemoveAll()
|
||||
end
|
||||
|
||||
function BASE:_SetDestructor()
|
||||
|
||||
local proxy = newproxy(true)
|
||||
local proxyMeta = getmetatable(proxy)
|
||||
|
||||
proxyMeta.__gc = function ()
|
||||
-- env.info("In __gc for " .. Child:GetClassNameAndID() )
|
||||
if self._Destructor then
|
||||
self:_Destructor()
|
||||
end
|
||||
end
|
||||
|
||||
-- keep the userdata from newproxy reachable until the object
|
||||
-- table is about to be garbage-collected - then the __gc hook
|
||||
-- will be invoked and the destructor called
|
||||
rawset( self, '__proxy', proxy )
|
||||
|
||||
end
|
||||
|
||||
--- This is the worker method to inherit from a parent class.
|
||||
-- @param #BASE self
|
||||
@@ -141,21 +159,7 @@ function BASE:Inherit( Child, Parent )
|
||||
setmetatable( Child, Parent )
|
||||
Child.__index = Child
|
||||
|
||||
local proxy = newproxy(true)
|
||||
local proxyMeta = getmetatable(proxy)
|
||||
|
||||
proxyMeta.__gc = function ()
|
||||
-- env.info("In __gc for " .. Child:GetClassNameAndID() )
|
||||
if Child._Destructor then
|
||||
Child:_Destructor()
|
||||
end
|
||||
end
|
||||
|
||||
-- keep the userdata from newproxy reachable until the object
|
||||
-- table is about to be garbage-collected - then the __gc hook
|
||||
-- will be invoked and the destructor called
|
||||
rawset(Child, '__proxy', proxy)
|
||||
|
||||
Child:_SetDestructor()
|
||||
end
|
||||
--self:T( 'Inherited from ' .. Parent.ClassName )
|
||||
return Child
|
||||
|
||||
@@ -98,6 +98,8 @@ function STATEMACHINE:AddProcess( From, Event, Process, ReturnEvents )
|
||||
sub.event = "Start"
|
||||
sub.ReturnEvents = ReturnEvents
|
||||
|
||||
-- Make the reference table weak.
|
||||
setmetatable( self.options.subs, { __mode = "v" } )
|
||||
self.options.subs[Event] = sub
|
||||
|
||||
self:_submap( self.subs, sub, nil )
|
||||
@@ -137,13 +139,16 @@ function STATEMACHINE:_submap( subs, sub, name )
|
||||
self:E( { sub = sub, name = name } )
|
||||
subs[sub.FromParent] = subs[sub.FromParent] or {}
|
||||
subs[sub.FromParent][sub.EventParent] = subs[sub.FromParent][sub.EventParent] or {}
|
||||
local Index = #subs[sub.FromParent][sub.EventParent] + 1
|
||||
subs[sub.FromParent][sub.EventParent][Index] = {}
|
||||
subs[sub.FromParent][sub.EventParent][Index].fsm = sub.fsm
|
||||
subs[sub.FromParent][sub.EventParent][Index].event = sub.event
|
||||
subs[sub.FromParent][sub.EventParent][Index].ReturnEvents = sub.ReturnEvents or {} -- these events need to be given to find the correct continue event ... if none given, the processing will stop.
|
||||
subs[sub.FromParent][sub.EventParent][Index].name = name
|
||||
subs[sub.FromParent][sub.EventParent][Index].fsmparent = self
|
||||
|
||||
-- Make the reference table weak.
|
||||
setmetatable( subs[sub.FromParent][sub.EventParent], { __mode = "k" } )
|
||||
|
||||
subs[sub.FromParent][sub.EventParent][sub] = {}
|
||||
subs[sub.FromParent][sub.EventParent][sub].fsm = sub.fsm
|
||||
subs[sub.FromParent][sub.EventParent][sub].event = sub.event
|
||||
subs[sub.FromParent][sub.EventParent][sub].ReturnEvents = sub.ReturnEvents or {} -- these events need to be given to find the correct continue event ... if none given, the processing will stop.
|
||||
subs[sub.FromParent][sub.EventParent][sub].name = name
|
||||
subs[sub.FromParent][sub.EventParent][sub].fsmparent = self
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user