GeoFormCache

Holds the four lists the geo form searches: the concatenated admin places, the concatenated health facilities, and the two historic lists. Each list is read from its workbook name on the first ask and held, so a keystroke in a search box of F_Geo scans memory. The concat lists are sorted once at that first read, so the hits of a search arrive in order with no sort per keystroke.

THE DEFAULT INSTANCE CARRIES THE SHARED CACHE

GeoModule.LoadGeo calls LoadFrom on the default instance on every form open, and FormLogicGeo reads the same instance on every search. LoadFrom drops the held lists, so each open reads each list at most once, and an open after a geobase import shows the new places. Create answers a separate instance for a caller that wants its own, which is what the tests build.

AFTER A STATE RESET THE CACHE ANSWERS EMPTY LISTS

Instance state dies on any unhandled error and any edit to the project, and the form outlives both. A read in that state answers an empty list, so a search shows nothing and raises nothing; the next LoadGeo fills the cache again. A read whose workbook name is missing raises, because that is a broken workbook the user has to hear about, and the callers that load the form hold a handler for it.

THE ANSWERED LISTS ARE HELD, SO TREAT THEM AS READ ONLY

ConcatList and HistoricList answer the held BetterArray itself. A copy per ask would pay the length of the geobase on every keystroke. A caller that wants to reorder or grow the answer builds its own copy.

Depends on: BetterArray

Factory

Create #

create

Create a new GeoFormCache over one workbook

Signature:

Public Function Create(ByVal sourceBook As Workbook) As GeoFormCache

Factory method that answers a separate instance loaded from the given workbook. Called on the predeclared instance. The shared cache the form reads is the predeclared instance itself, filled through LoadFrom.

Parameters:

  • sourceBook: Workbook. The workbook whose names are read.

Returns: GeoFormCache. A loaded instance.

Throws:

  • ProjectError.ObjectNotInitialized When the workbook is Nothing.

Internal members (not exported)

Loading

LoadFrom #

load-from

Point the cache at a workbook and drop the held lists

Signature:

Public Sub LoadFrom(ByVal sourceBook As Workbook)

Records the workbook and empties the cache, so the next ask of each list reads it fresh. LoadGeo calls this once per form open, which is what keeps the form current after a geobase import.

Parameters:

Throws:


Refresh #

refresh

Drop the held lists and keep the workbook

Signature:

Public Sub Refresh()

The next ask of each list reads it fresh from its workbook name.


Clear #

clear

Drop the held lists and the workbook

Signature:

Public Sub Clear()

Puts the cache back in its unloaded state, where every ask answers an empty list.


Reading

ConcatList #

concat-list

The concatenated places of one scope, sorted

Signature:

Public Function ConcatList(ByVal scope As Byte) As BetterArray

The admin scope reads "adm4_concat" and the facility scope reads "hf_concat". The list is read and sorted on the first ask and held until LoadFrom, Refresh or Clear drops it. An unloaded cache answers an empty list.

Parameters:

Returns: BetterArray. The held list. Treat it as read only.

Throws:


HistoricList #

historic-list

The historic places of one scope, in table order

Signature:

Public Function HistoricList(ByVal scope As Byte) As BetterArray

The admin scope reads "histo_geo" and the facility scope reads "histo_hf". The historic table shows in the order its rows hold, which is the order the user validated places in, so this list is held unsorted.

Parameters:

Returns: BetterArray. The held list. Treat it as read only.

Throws:


Implementation

ReadList #

Read one list from its workbook name

Signature:

Private Function ReadList(ByVal rangeName As String, _
                          ByVal sorted As Boolean) As BetterArray

One crossing per list per load. An unloaded cache answers an empty list; a loaded cache whose name is missing lets the resolve raise.

Parameters:

Returns: BetterArray. The list read, or an empty one with no workbook held.


GuardScope #

Refuse a scope outside the two the form knows

Signature:

Private Sub GuardScope(ByVal scope As Byte)

GeoScopeBoth exists on the enum and has no list in the form, so an unknown scope raises here. An unknown scope used to mean facility in silence elsewhere in the geo code, and this class refuses it the way the module now does.

Parameters:

Throws:


Error Handling

ThrowError #

throw-error

Raise a ProjectError-based exception

Signature:

Private Sub ThrowError(ByVal errNumber As Long, ByVal message As String)

Wrapper around Err.Raise that standardises the source to CLASS_NAME.

Parameters:

Throws:


Used in (4 file(s))