Macaw.Frame.Layers (macaw_frame v0.1.0)

Copy Markdown View Source

The layer registry (spec/04 §2): layer kinds are members of packages, as macaw_data's operations are. A package is a module whose __members__/0 lists its modules; a member's behavior is read from its @behaviours.

registry/1 builds %Macaw.Frame.Layers.Registry{} from an explicit list:

  • default closed: macaw_frame's own package (Macaw.Frame.Package) is always in, anything else only when listed; a merely loaded module is not reachable and no application environment is read;
  • duplicates fail at build: two kinds of one name are {[:layer, name], {:named_twice, module, other}}; a listed member implementing none of the frame's or macaw_data's behaviors is {[package, member], :no_behavior}; a module that is no package {[module], :not_a_package}; every fault at once;
  • names are strings, matched by spelling: fetch/2, kinds/1 (sorted) and digest/1, a term digest of every member's name and module independent of the order of registration.

The same package list builds the operations registry (operations/1): the package's Macaw.Data.Transform members, the frame's spatial steps, join macaw_data's own. document/1 answers the registry a Frame module hands the frame document (%{layers, models, operations}, spec/02 §12).

The registry is fixed per Frame module (use Macaw.Frame.Component, packages: [...], spec/01): built when the module is compiled, never carried in the component context.

Summary

Functions

The registry's digest: the kernel's term digest of every member's name and module, sorted, so it ignores the order of registration and changes with membership.

The registry a Frame module hands the frame document (spec/02 §12): {:ok, %{layers: %{name => module}, models: %{name => module}, operations: registry, catalogs: %{id => module}}} from one package list, its catalog fragments those its packages list (spec/13 §1.3), or every fault of the four builds at once.

The kind a registry holds by name, read by spelling: {:ok, module} or :error.

Every kind name the registry holds, sorted.

The operations registry the same packages build (§2): Macaw.Data.Operations.registry/1 of the package list, macaw_frame's package always in.

The registry of the kinds the packages hold, macaw_frame's own always in: {:ok, registry}, or every fault at once.

Functions

digest(registry)

@spec digest(term()) :: term()

The registry's digest: the kernel's term digest of every member's name and module, sorted, so it ignores the order of registration and changes with membership.

document(packages)

@spec document(term()) :: {:ok, map()} | {:error, [Macaw.Base.Fault.t(), ...]}

The registry a Frame module hands the frame document (spec/02 §12): {:ok, %{layers: %{name => module}, models: %{name => module}, operations: registry, catalogs: %{id => module}}} from one package list, its catalog fragments those its packages list (spec/13 §1.3), or every fault of the four builds at once.

fetch(registry, name)

@spec fetch(term(), term()) :: {:ok, module()} | :error

The kind a registry holds by name, read by spelling: {:ok, module} or :error.

iex> {:ok, registry} = Macaw.Frame.Layers.registry([])
iex> Macaw.Frame.Layers.fetch(registry, "nowhere")
:error

kinds(registry)

@spec kinds(term()) :: [String.t()]

Every kind name the registry holds, sorted.

operations(packages)

@spec operations(term()) :: {:ok, term()} | {:error, [Macaw.Base.Fault.t(), ...]}

The operations registry the same packages build (§2): Macaw.Data.Operations.registry/1 of the package list, macaw_frame's package always in.

registry(packages)

@spec registry(term()) ::
  {:ok, Macaw.Frame.Layers.Registry.t()} | {:error, [Macaw.Base.Fault.t(), ...]}

The registry of the kinds the packages hold, macaw_frame's own always in: {:ok, registry}, or every fault at once.