# The ports: repository and unit-of-work interfaces in the domain's terms.
# The domain itself is the aggregate page's library, unchanged.
add_library(arch_repo_store INTERFACE)
target_include_directories(arch_repo_store INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/store)
target_link_libraries(arch_repo_store INTERFACE arch_agg_domain)

# Two storage adapters, in memory and in a file, sharing one unit of work.
add_library(arch_repo_adapters STATIC
  adapters/tables.cpp adapters/staged_unit_of_work.cpp adapters/memory_storage.cpp
  adapters/file_format.cpp adapters/file_storage.cpp)
target_include_directories(arch_repo_adapters PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/adapters)
target_link_libraries(arch_repo_adapters PUBLIC arch_repo_store)

# The application layer sees only the ports, never an adapter.
add_library(arch_repo_app STATIC app/registry.cpp app/commands.cpp)
target_include_directories(arch_repo_app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/app)
target_link_libraries(arch_repo_app PUBLIC arch_repo_store)

lld_add_example(arch_enrollment_repository SOURCES main.cpp EXPECTED_OUTPUT expected_output.txt)
target_link_libraries(arch_enrollment_repository PRIVATE arch_repo_app arch_repo_adapters)

lld_add_test(arch_repo_contract_tests SOURCES tests/test_storage_contract.cpp)
target_link_libraries(arch_repo_contract_tests PRIVATE arch_repo_adapters)

lld_add_test(arch_repo_file_tests SOURCES tests/test_file_storage.cpp)
target_link_libraries(arch_repo_file_tests PRIVATE arch_repo_adapters)

lld_add_test(arch_repo_registry_tests SOURCES tests/test_registry.cpp)
target_link_libraries(arch_repo_registry_tests PRIVATE arch_repo_app arch_repo_adapters)
