FSTLevelDBMutationQueue.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/Local/FSTMutationQueue.h"
  18. #ifdef __cplusplus
  19. #include <memory>
  20. namespace leveldb {
  21. class DB;
  22. }
  23. #endif
  24. @class FSTLevelDB;
  25. @class FSTLocalSerializer;
  26. @class FSTUser;
  27. @protocol FSTGarbageCollector;
  28. NS_ASSUME_NONNULL_BEGIN
  29. /** A mutation queue for a specific user, backed by LevelDB. */
  30. @interface FSTLevelDBMutationQueue : NSObject <FSTMutationQueue>
  31. - (instancetype)init __attribute__((unavailable("Use a static constructor")));
  32. /** The garbage collector to notify about potential garbage keys. */
  33. @property(nonatomic, weak, readwrite, nullable) id<FSTGarbageCollector> garbageCollector;
  34. #ifdef __cplusplus
  35. /**
  36. * Creates a new mutation queue for the given user, in the given LevelDB.
  37. *
  38. * @param user The user for which to create a mutation queue.
  39. * @param db The LevelDB in which to create the queue.
  40. */
  41. + (instancetype)mutationQueueWithUser:(FSTUser *)user
  42. db:(std::shared_ptr<leveldb::DB>)db
  43. serializer:(FSTLocalSerializer *)serializer;
  44. /**
  45. * Returns one larger than the largest batch ID that has been stored. If there are no mutations
  46. * returns 0. Note that batch IDs are global.
  47. */
  48. + (FSTBatchID)loadNextBatchIDFromDB:(std::shared_ptr<leveldb::DB>)db;
  49. #endif
  50. @end
  51. NS_ASSUME_NONNULL_END