@startuml

participant memmgr as ":b10-memmgr"
[-> memmgr: new/initial config\n(datasrc cfg)
activate memmgr

participant list as ":Configurable\nClientList"
create list
memmgr -> list: <<construct>>

memmgr -> list: configure(cfg)
activate list

participant CacheConfig as ":CacheConfig"
create CacheConfig
list -> CacheConfig: <<construct>> (cfg)

participant zt_segment as ":ZoneTable\nSegment\n(Mapped)"
create zt_segment
list -> zt_segment: <<construct>>

list -> zt_segment: isWritable()
activate zt_segment
note over zt_segment: Segment not writable\nwhen not reset
zt_segment --> list: false
deactivate zt_segment

deactivate list

memmgr -> list: getStatus()
activate list
list --> memmgr: DataSourceStatus[]
deactivate list

loop for each datasrc with mapped segment

memmgr -> list: resetMemorySegment\n(datasrc_name,\nREAD_WRITE,\nsegmentparam)
activate list

list -> zt_segment: reset\n(READ_WRITE,\nsegmentparam)
activate zt_segment

participant segment as "seg1:Memory\nSegment\n(Mapped)"
create segment
zt_segment -> segment: <<construct>>

participant segment.2 as "seg2:Memory\nSegment\n(Mapped)"

participant ZoneTable as ":ZoneTable"
create ZoneTable
zt_segment -> ZoneTable: <<construct>>

deactivate zt_segment
deactivate list

memmgr -> list: getZoneTableAccessor\n(datasrc_name,\ncache=true)
activate list
list -> memmgr: ZoneTableAccessor
deactivate list


loop for each zone given by ZoneTableIterator

memmgr -> list: getCachedZoneWriter\n(zone_name)
activate list

list -> CacheConfig: getLoadAction()
activate CacheConfig

participant LoadAction as "la:LoadAction"
create LoadAction
CacheConfig -> LoadAction: <<construct>>

CacheConfig --> list : la

deactivate CacheConfig

participant ZoneWriter as "zw:ZoneWriter"
create ZoneWriter
list -> ZoneWriter: <<construct>> (la)

list --> memmgr: zw

deactivate list


memmgr -> ZoneWriter: load()
activate ZoneWriter
ZoneWriter -> LoadAction: (funcall)
activate LoadAction

participant ZoneData as "zd:ZoneData"
create ZoneData
LoadAction -> ZoneData: <<construct>> via helpers

LoadAction --> ZoneWriter: zd
deactivate LoadAction
deactivate ZoneWriter

memmgr -> ZoneWriter: install()
activate ZoneWriter

ZoneWriter -> ZoneTable: addZone(zd)
activate ZoneTable
ZoneTable --> ZoneWriter: NULL (no old data)
deactivate ZoneTable

deactivate ZoneWriter

end

[<- memmgr: command to\nmodules\n(datasrc_name,\nsegmentparam)
[--> memmgr: ack from all\nmodules

memmgr -> list: resetMemorySegment\n(datasrc_name,\nREAD_WRITE,\nsegmentparam)
activate list

list -> zt_segment: reset\n(READ_WRITE,\nsegmentparam)
activate zt_segment

zt_segment -> segment: <<destroy>>
destroy segment
create segment.2
zt_segment -> segment.2: <<construct>>

deactivate zt_segment
deactivate list

note left of memmgr: load zone\nfor each zone\ngiven by\nZoneTableIterator

end

[<-- memmgr

deactivate memmgr

@enduml
