Skip to content

SamplingPackageRegistry

The singleton registry of all SamplingPackages used in an app.

An app registers each external sampling package here at startup, before it configures the SmartPhoneClientManager. The registry then knows which measure types, Probes and devices are available on this phone.

Key points:

See the CAMS GitHub repo for an overview of available sampling packages.

SamplingPackageRegistry().register(ContextSamplingPackage());
await SmartPhoneClientManager().configure();

Constructors

SamplingPackageRegistry

SamplingPackageRegistry()

Returns the singleton SamplingPackageRegistry.

Properties

dataTypes

List<DataTypeMetaData> get dataTypes

The combined list of all data types in all packages.

packages

List<SamplingPackage> get packages

The registered packages, in registration order.

samplingSchemes

DataTypeSamplingSchemeMap get samplingSchemes

The combined sampling schemes for all measure types in all packages.

Used as the last fallback for a Probe.samplingConfiguration and to find the permissions a measure needs.

Methods

create

Probe? create(
  1. String type
)

Creates a new Probe for the data type.

Asks the first registered package that supports type to create the probe, and sets the probe's Probe.deviceManager to the package's device manager. If more than one package supports type, a warning is logged.

Returns null if no probe is found for type, e.g., when the probe is not available on this OS or its package is not registered.

lookup

Set<SamplingPackage> lookup(
  1. String type
)

Returns the SamplingPackages that support the data type.

Typically, only one package supports a specific type. However, if more than one package does, all packages are returned. Can be an empty list.

register

void register(
  1. SamplingPackage package
)

Registers package.

Also adds the package's data types to CarpDataTypes, registers its SamplingPackage.deviceManager in the DeviceController, and calls SamplingPackage.onRegister.