FSTTargetIDGenerator.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "Firestore/Source/Core/FSTTypes.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. /**
  20. * FSTTargetIDGenerator generates monotonically increasing integer IDs. There are separate
  21. * generators for different scopes. While these generators will operate independently of each
  22. * other, they are scoped, such that no two generators will ever produce the same ID. This is
  23. * useful, because sometimes the backend may group IDs from separate parts of the client into the
  24. * same ID space.
  25. */
  26. @interface FSTTargetIDGenerator : NSObject
  27. /**
  28. * Creates and returns the FSTTargetIDGenerator for the local store.
  29. *
  30. * @param after An ID to start at. Every call to nextID will return an ID > @a after.
  31. * @return A shared instance of FSTTargetIDGenerator.
  32. */
  33. + (instancetype)generatorForLocalStoreStartingAfterID:(FSTTargetID)after;
  34. /**
  35. * Creates and returns the FSTTargetIDGenerator for the sync engine.
  36. *
  37. * @param after An ID to start at. Every call to nextID will return an ID > @a after.
  38. * @return A shared instance of FSTTargetIDGenerator.
  39. */
  40. + (instancetype)generatorForSyncEngineStartingAfterID:(FSTTargetID)after;
  41. - (id)init __attribute__((unavailable("Use a static constructor method.")));
  42. /** Returns the next ID in the sequence. */
  43. - (FSTTargetID)nextID;
  44. @end
  45. NS_ASSUME_NONNULL_END