FIRModelManager.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #import <Foundation/Foundation.h>
  2. @class FIRLocalModel;
  3. @class FIRRemoteModel;
  4. NS_ASSUME_NONNULL_BEGIN
  5. /** Manages models that are used by MLKit features. */
  6. NS_SWIFT_NAME(ModelManager)
  7. @interface FIRModelManager : NSObject
  8. /**
  9. * Returns the `ModelManager` instance for the default Firebase app. The default Firebase app
  10. * instance must be configured before calling this method; otherwise, raises `FIRAppNotConfigured`
  11. * exception. Models hosted in non-default Firebase apps are currently not supported. The returned
  12. * model manager is thread safe.
  13. *
  14. * @return The `ModelManager` instance for the default Firebase app.
  15. */
  16. + (instancetype)modelManager NS_SWIFT_NAME(modelManager());
  17. /** Unavailable. Use the `modelManager()` class method. */
  18. - (instancetype)init NS_UNAVAILABLE;
  19. /**
  20. * Registers a remote model. The model name is unique to each remote model and can only be
  21. * registered once with a given instance of `ModelManager`. The model name should be the same name
  22. * used when the model was uploaded to the Firebase Console. It's OK to separately register a remote
  23. * and local model with the same name for a given instance of `ModelManager`.
  24. *
  25. * @param remoteModel The remote model to register.
  26. * @return Whether the registration was successful. Returns `NO` if the given `remoteModel` is
  27. * invalid or has already been registered.
  28. */
  29. - (BOOL)registerRemoteModel:(FIRRemoteModel *)remoteModel;
  30. /**
  31. * Registers a local model. The model name is unique to each local model and can only be registered
  32. * once with a given instance of `ModelManager`. It's OK to separately register a remote and local
  33. * model with the same name for a given instance of `ModelManager`.
  34. *
  35. * @param localModel The local model to register.
  36. * @return Whether the registration was successful. Returns `NO` if the given `localModel` is
  37. * invalid or has already been registered.
  38. */
  39. - (BOOL)registerLocalModel:(FIRLocalModel *)localModel;
  40. /**
  41. * Returns the registered remote model with the given name. Returns `nil` if the model was never
  42. * registered with this model manager.
  43. *
  44. * @param name Name of the remote model.
  45. * @return The remote model that was registered with the given name. Returns `nil` if the model was
  46. * never registered with this model manager.
  47. */
  48. - (nullable FIRRemoteModel *)remoteModelWithName:(NSString *)name;
  49. /**
  50. * Returns the registered local model with the given name. Returns `nil` if the model was never
  51. * registered with this model manager.
  52. *
  53. * @param name Name of the local model.
  54. * @return The local model that was registered with the given name. Returns `nil` if the model was
  55. * never registered with this model manager.
  56. */
  57. - (nullable FIRLocalModel *)localModelWithName:(NSString *)name;
  58. @end
  59. NS_ASSUME_NONNULL_END