Overview
The QuerySystem is small and mostly data-driven. It has one coordinator, QueryFactory, and one message class, Query. The rest of the system defines keys, enums, and the query contract.
Coordinators
QueryFactory
Static entry point for callers. Each method:
- Creates a
Querywith a targetDomainandQueryVerb.Get. - Sets
QueryKeys.QuerySubjectin the input params to the matchingQuerySubjectsvalue. - Calls
BusUtility.AskAndGetwith the matching result key, and returns the typed value.
QueryFactory does not hold state. It is the only class in the system that talks to the bus, and it does so through BusUtility (dependency).
Current methods:
GetCurrentPlatform()routes toDomain.Release.GetTimeInLevel()routes toDomain.Level.GetCurrentLevel()routes toDomain.Game.GetGameSpeed()routes toDomain.Game.
Message classes
Query
The message that carries a request and its answer. Owns its Params for input, its Result for output, and its Status. Callers create it through QueryFactory or directly, then send it through BusUtility (dependency).
QueryKeys and QueryKeyNames
QueryKeyNames holds the string names. QueryKeys holds the typed ParamKey fields built from those names. Use QueryKeys in calls to Params.Set, Params.Get, and Params.Has.
Interfaces
IQuery
The contract for a query. The query bus (dependency) delivers IQuery instances to handlers, which read TargetDomain, Verb, and Params, then write Result and Status. Handlers registered by owning systems must follow the documented rule that they do not change state while answering.
No handler interface is defined in these blocks. Handler registration happens on the query bus, which is described in the Bus dependency.
Enums
QueryVerb:Get,Own,Has.QueryStatus:Pending,Success,Failure.QuerySubjects:Platform,Time,Level,Speed.
Interactions with dependencies
| Dependency | How this system uses it |
|---|---|
Contracts (Domain) | Each query is addressed to a Domain. The query bus routes by it. |
Params (Params, ParamKey) | Holds the query's input and result values. QueryKeys supplies the keys. |
Bus (BusUtility) | QueryFactory sends queries and reads answers through AskAndGet. |
Bus (QueryBus, BusRegistry) | Routes each query to the handler for its domain, reached through the service locator. |
Bus (MessageBus) | Queues queries until a handler is registered and the domain is ready, then releases them in FIFO order. |