Class Registry

java.lang.Object
com.viam.sdk.core.resource.Registry

public class Registry extends Object
The global registry of robotic parts. **NB** The Registry should almost never be used directly The Registry keeps track of the types of Resources that are available on robots using this SDK. All the base resource types are pre-registered (e.g. Arm, Motor). If you create a new resource type that is not an extension of any of the existing base resource types, then you must register said resource using Registry.register(...)
  • Constructor Details

    • Registry

      public Registry()
  • Method Details

    • registerSubtype

      public static <ResourceT extends Resource> void registerSubtype(ResourceRegistration<ResourceT> registration) throws DuplicateResourceSubtypeException
      Register a Subtype with the Registry
      Type Parameters:
      ResourceT - The resource type
      Parameters:
      registration - Object containing registration data for the subtype
      Throws:
      DuplicateResourceSubtypeException - Thrown if the Subtype to register is already in the registry
    • registerResourceCreator

      public static void registerResourceCreator(Subtype subtype, Model model, ResourceCreatorRegistration registration) throws DuplicateModelException
      Register a specific Model and validator function for the specific resource Subtype with the Registry
      Parameters:
      subtype - The Subtype of the resource
      model - The Model of the resource
      registration - The registration functions of the model
      Throws:
      DuplicateModelException - Thrown if the Subtype and Model pairing is already registered
    • lookupSubtype

      public static ResourceRegistration<?> lookupSubtype(Subtype subtype)
      Lookup and retrieve a registered Subtype by its name
      Parameters:
      subtype - The subtype of the resource
      Returns:
      The registration object of the resource
    • lookupResourceCreator

      public static ResourceCreator lookupResourceCreator(Subtype subtype, Model model)
    • lookupValidator

      public static Optional<Function<Robot.ComponentConfig,Set<String>>> lookupValidator(Subtype subtype, Model model)
      Lookup and retrieve a registered validator function by its subtype and model. If there is none, return None
      Parameters:
      subtype - The Subtype of the resource
      model - The Model of the resource
      Returns:
      The function to validate the resource
    • registeredSubtypes

      public static Map<Subtype,ResourceRegistration<?>> registeredSubtypes()
      The dictionary of all registered resources - Key: Subtype of the resource - Value: The registration object for the resource
      Returns:
      All registered resources
    • registeredResourceCreators

      public static Map<Registry.SubtypeModel,ResourceCreatorRegistration> registeredResourceCreators()
      The dictionary of all registered resources - Key: subtype/model - Value: The ResourceCreatorRegistration for the resource
      Returns:
      All registered resources