Skip to content

Refactoring the access to space related functions to move towards multispace models #910

Open
@Tortar

Description

Take this function:

function id_in_position(pos, model::ABM{<:GridSpaceSingle})
    return abmspace(model).stored_ids[pos...]
end

we could refactor this code so that to have:

id_in_position(pos, model::ABM) = id_in_position(pos, abmspace(model), model) # this can be actually done only one time, probably
                                                                              # to put in space_interaction_API.jl
function id_in_position(pos, space::GridSpaceSingle, ::ABM)
    return space.stored_ids[pos...]
end

What does this allow? It gets us nearer to possible implementation of multispace models since we need to give the possibility to the user to access the space-related function dispatching on the space when implementing a multi-space extension (which can be just as simple as a namedtuple of spaces), so that to allow to refer to different spaces inside his/her code.

Note that this is a costless abstraction.

cc: @Datseris

Related to #719, #720

Metadata

Assignees

No one assigned

    Labels

    designDesign-related discussions for APIs, Interfaces, etc.modelRelated to an existing or new model implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions