[CommCoreModule] introduce BaseDataStore template class
Summary:
Problems I want to solve:
- Code duplication - this part of code is duplicated at least 5 times (and will grow).
- Lack of separation - a lot of not related code like parsing is here, this can be grouped logically.
How it works:
- This template class provides two generic functions which will be reused (processStoreOperations, processStoreOperationsSync) - this solves problem 1.
- Has two pure virtual methods which need to be overridden (parseDBDataStore, createOperations), those methods are specialized for each data type (Messages, Threads, etc.) - this solves problem 2.
Why .h file?
When a template is used in C++, the compiler needs access to the entire template definition (not just a declaration) because it needs to generate the code for the specific instantiation at the compile time. (source).
Why not static methods when the class does not have a state?
I wanted to ensure that each child class (which will inherit from BaseDataStore) will override methods for parsing and creating ops. This can not be achieved easily with static methods - but I am open to modifying if someone has valid suggestions.
For more details check the next diff in the stack.
Depends on D8601
Test Plan: Build iOS and Android (rest is tested in detailed implementation in next diffs).
Reviewers: michal, jon, atul, tomek, marcin
Reviewed By: michal, jon, atul, tomek
Subscribers: marcin, ashoat
Differential Revision: https://phab.comm.dev/D8603