Skip to content

Commit

Permalink
Progress with migration to ObjectBox
Browse files Browse the repository at this point in the history
  • Loading branch information
JaffaKetchup committed Nov 24, 2023
1 parent cad382e commit ef3d56f
Show file tree
Hide file tree
Showing 19 changed files with 873 additions and 292 deletions.
2 changes: 1 addition & 1 deletion lib/flutter_map_tile_caching.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ part 'src/bulk_download/manager.dart';
part 'src/bulk_download/thread.dart';
part 'src/bulk_download/tile_event.dart';
part 'src/fmtc.dart';
part 'src/misc/store_db_impl.dart';
part 'src/misc/with_backend_access.dart';
part 'src/providers/tile_provider.dart';
part 'src/regions/base_region.dart';
part 'src/regions/circle.dart';
Expand Down
2 changes: 2 additions & 0 deletions lib/src/backend/export_plus.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export 'export_std.dart';
export 'impl_tools/errors.dart';
export 'impl_tools/no_sync.dart';
export 'interfaces/models.dart';
1 change: 0 additions & 1 deletion lib/src/backend/export_std.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export 'errors.dart';
export 'impls/objectbox/backend.dart';
export 'interfaces/backend.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ class RootUnavailable extends Error {
'RootUnavailable: The requested backend/root was unavailable';
}

/// Indicates that the backend/root structure could not be initialised, because
/// it was already initialised.
///
/// Try destroying it first.
///
/// To be thrown by backend implementations. For resolution by end-user.
class RootAlreadyInitialised extends Error {
@override
String toString() =>
'RootUnavailable: The requested backend/root could not be initialised because it was already initialised';
}

/// Indicates that the specified store structure was not available for use in
/// operations, likely because it didn't exist
///
Expand Down Expand Up @@ -41,3 +53,19 @@ class TileCannotUpdate extends Error {
String toString() =>
'TileCannotUpdate: The requested tile ("$url") did not exist, and so cannot be updated';
}

/// Indicates that the backend implementation does not support the invoked
/// synchronous operation.
///
/// Use the asynchronous version instead.
///
/// Note that there is no equivalent error for async operations: if there is no
/// specific async version of an operation, it should redirect to the sync
/// version.
///
/// To be thrown by backend implementations. For resolution by end-user.
class SyncOperationUnsupported extends Error {
@override
String toString() =>
'SyncOperationUnsupported: The backend implementation does not support the invoked synchronous operation.';
}
135 changes: 135 additions & 0 deletions lib/src/backend/impl_tools/no_sync.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import 'dart:typed_data';

import '../interfaces/backend.dart';
import 'errors.dart';

/// A shortcut to declare that an [FMTCBackend] does not support any synchronous
/// versions of methods
mixin FMTCBackendNoSync implements FMTCBackend {
/// This synchronous method is unsupported by this implementation - use
/// [initialise] instead
@override
Never initialiseSync({
String? rootDirectory,
int? maxDatabaseSize,
Map<String, Object> implSpecificArgs = const {},
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncInitialise = false;

/// This synchronous method is unsupported by this implementation - use
/// [destroy] instead
@override
Never destroySync({
bool deleteRoot = false,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncDestroy = false;

/// This synchronous method is unsupported by this implementation - use
/// [createStore] instead
@override
Never createStoreSync({
required String storeName,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncCreateStore = false;

/// This synchronous method is unsupported by this implementation - use
/// [resetStore] instead
@override
Never resetStoreSync({
required String storeName,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncResetStore = false;

/// This synchronous method is unsupported by this implementation - use
/// [renameStore] instead
@override
Never renameStoreSync({
required String currentStoreName,
required String newStoreName,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncRenameStore = false;

/// This synchronous method is unsupported by this implementation - use
/// [deleteStore] instead
@override
Never deleteStoreSync({
required String storeName,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncDeleteStore = false;

/// This synchronous method is unsupported by this implementation - use
/// [getStoreSize] instead
@override
Never getStoreSizeSync({
required String storeName,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncGetStoreSize = false;

/// This synchronous method is unsupported by this implementation - use
/// [getStoreLength] instead
@override
Never getStoreLengthSync({
required String storeName,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncGetStoreLength = false;

/// This synchronous method is unsupported by this implementation - use
/// [readTile] instead
@override
Never readTileSync({
required String url,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncReadTile = false;

/// This synchronous method is unsupported by this implementation - use
/// [writeTile] instead
@override
Never writeTileSync({
required String storeName,
required String url,
required Uint8List? bytes,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncWriteTile = false;

/// This synchronous method is unsupported by this implementation - use
/// [deleteTile] instead
@override
Never deleteTileSync({
required String storeName,
required String url,
}) =>
throw SyncOperationUnsupported();

@override
final supportsSyncDeleteTile = false;
}
Loading

0 comments on commit ef3d56f

Please sign in to comment.