Commit bf68646
Changed files (2)
health_data_store
lib
src
data_providers
repositories
health_data_store/lib/src/data_providers/data_provider.dart
@@ -0,0 +1,21 @@
+import 'dart:collection';
+
+import 'package:health_data_store/health_data_store.dart';
+
+/// A data provider provides access to the data.
+///
+/// It interacts with the databases on a low level and only supports basic CRUD
+/// operations.
+///
+/// Tables are structured in a way that they have a id ([int]) as a primary
+/// key and have one or more other columns associated with that key.
+abstract class DataProvider<T> {
+ /// Gets all entries in the inclusive range.
+ Future<UnmodifiableListView<(int,T)>> getInRange(DateRange range);
+
+ /// Sets the data at [entryID] to [value].
+ Future<void> set(int entryID, T value);
+
+ /// Removes the value associated with this [entryID].
+ Future<void> remove(int entryID);
+}
health_data_store/lib/src/repositories/repository.dart
@@ -0,0 +1,22 @@
+import 'dart:collection';
+
+import 'package:health_data_store/src/data_providers/data_provider.dart';
+import 'package:health_data_store/src/types/date_range.dart';
+
+/// A repository is a abstraction around multiple [DataProvider]s.
+///
+/// Repositories wrap the primitive values of [DataProvider]s into more complex
+/// types and provides domain models for the application.
+abstract class Repository<T> {
+ /// Adds a new value to the repository.
+ Future<void> add(T value);
+
+ /// Attempts to remove a value from the repository.
+ ///
+ /// This should only be called for values for values that are known to be in
+ /// the repository.
+ Future<void> remove(T value);
+
+ /// Inclusively returns all values in the specified [range].
+ Future<UnmodifiableListView<T>> get(DateRange range);
+}