Package com.viam.sdk.core.resource
Class Registry
java.lang.Object
com.viam.sdk.core.resource.Registry
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(...)
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceCreator
lookupResourceCreator
(Subtype subtype, Model model) static ResourceRegistration<?>
lookupSubtype
(Subtype subtype) Lookup and retrieve a registered Subtype by its namestatic Optional<Function<Robot.ComponentConfig,
Set<String>>> lookupValidator
(Subtype subtype, Model model) Lookup and retrieve a registered validator function by its subtype and model.The dictionary of all registered resources - Key: subtype/model - Value: The ResourceCreatorRegistration for the resourcestatic Map<Subtype,
ResourceRegistration<?>> The dictionary of all registered resources - Key: Subtype of the resource - Value: The registration object for the resourcestatic void
registerResourceCreator
(Subtype subtype, Model model, ResourceCreatorRegistration registration) Register a specific Model and validator function for the specific resource Subtype with the Registrystatic <ResourceT extends Resource>
voidregisterSubtype
(ResourceRegistration<ResourceT> registration) Register a Subtype with the Registry
-
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 resourcemodel
- The Model of the resourceregistration
- The registration functions of the model- Throws:
DuplicateModelException
- Thrown if the Subtype and Model pairing is already registered
-
lookupSubtype
Lookup and retrieve a registered Subtype by its name- Parameters:
subtype
- The subtype of the resource- Returns:
- The registration object of the resource
-
lookupResourceCreator
-
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 resourcemodel
- The Model of the resource- Returns:
- The function to validate the resource
-
registeredSubtypes
The dictionary of all registered resources - Key: Subtype of the resource - Value: The registration object for the resource- Returns:
- All registered resources
-
registeredResourceCreators
The dictionary of all registered resources - Key: subtype/model - Value: The ResourceCreatorRegistration for the resource- Returns:
- All registered resources
-