15 changed files with 189 additions and 15 deletions
@ -0,0 +1,12 @@ |
|||||||
|
{ |
||||||
|
"version": 3, |
||||||
|
"configurePresets": [ |
||||||
|
{ |
||||||
|
"name": "default", |
||||||
|
"toolchainFile": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", |
||||||
|
"cacheVariables": { |
||||||
|
"CMAKE_EXPORT_COMPILE_COMMANDS": "TRUE" |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,54 @@ |
|||||||
|
# C++17 AutoStore Implementation Plan |
||||||
|
|
||||||
|
This document outlines the steps to implement the C++17 version of the AutoStore application. Implemented classes should use `nxl::` namespace prefix. |
||||||
|
|
||||||
|
## Phase 1: Project Scaffolding & Build System |
||||||
|
|
||||||
|
- [x] Initialize a CMake project structure. |
||||||
|
- [x] Set up the root `CMakeLists.txt` to manage the `app` and `lib` subdirectories. |
||||||
|
- [x] Create the `lib` directory for the static library. |
||||||
|
- [x] Create the `app` directory for the executable. |
||||||
|
- [x] Configure `vcpkg` for dependency management and integrate it with CMake. |
||||||
|
- [x] Add a dependency for an HTTP library (e.g., `cpp-httplib`) via `vcpkg`. |
||||||
|
- [x] Add a dependency for a testing framework (e.g., `catch2`) via `vcpkg`. |
||||||
|
|
||||||
|
## Phase 2: Library (`lib`) - Dummy Implementation |
||||||
|
|
||||||
|
- [x] Create the directory structure for the library: `lib/src`, `lib/include`. |
||||||
|
- [x] Create `lib/CMakeLists.txt` to build a static library. |
||||||
|
- [x] In `lib/include/autostore`, define the public interface for the `App` to use. |
||||||
|
- [x] Create a dummy `AutoStore` class in `lib/include/autostore/AutoStore.h` and a source file in `lib/src/AutoStore.cpp`. |
||||||
|
- [ ] Define dummy classes for core domain and application logic inside the library (e.g., `ItemRepository`, `UserService`, etc.) to establish the architecture. These will be private to the library initially. |
||||||
|
|
||||||
|
## Phase 3: Application (`app`) - Dummy Implementation |
||||||
|
|
||||||
|
- [ ] Create the directory structure for the application: `app/src`. |
||||||
|
- [x] Create `app/CMakeLists.txt` to build the executable. |
||||||
|
- [ ] Link the `app` against the `lib` static library. |
||||||
|
- [ ] Implement the main `App` class in `app/src/App.h` and `app/src/App.cpp`. |
||||||
|
- [ ] The `App` class will have a constructor `App(int argc, char** argv)` and an `exec()` method. |
||||||
|
- [ ] Implement signal handling (for `SIGINT`, `SIGTERM`) in the `App` class for graceful shutdown. |
||||||
|
- [x] In `app/src/Main.cpp`, instantiate and run the `App` class. |
||||||
|
- [ ] Ensure the project compiles and links successfully with the dummy implementations. |
||||||
|
|
||||||
|
## Phase 4: Core Logic Implementation |
||||||
|
|
||||||
|
- [ ] Implement the Domain layer in `lib/src/domain`. |
||||||
|
- [ ] Implement the Application layer in `lib/src/application`. |
||||||
|
- [ ] Implement the Infrastructure layer in `lib/src/infrastructure` (e.g., file-based persistence, HTTP client for ordering). |
||||||
|
- [ ] Implement the Presentation layer (HTTP API) using the chosen HTTP library. |
||||||
|
- [ ] Implement the startup logic to check for expired items. |
||||||
|
- [ ] Implement a background mechanism (e.g., a thread) to periodically check for expired items. |
||||||
|
|
||||||
|
## Phase 5: Testing |
||||||
|
|
||||||
|
- [ ] Set up a `tests` directory. |
||||||
|
- [ ] Create `tests/CMakeLists.txt` to build the test runner. |
||||||
|
- [ ] Write unit tests for the Domain layer. |
||||||
|
- [ ] Write unit tests for the Application layer, using mocks for infrastructure interfaces. |
||||||
|
- [ ] Write integration tests for the Infrastructure layer. |
||||||
|
|
||||||
|
## Phase 6: Containerization |
||||||
|
|
||||||
|
- [x] Create a `Dockerfile` to build the C++ application in a container. |
||||||
|
- [x] Create a `docker-compose.yml` file to easily build and run the application. |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
#include "App.h" |
||||||
|
#include "autostore/AutoStore.h" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
namespace nxl |
||||||
|
{ |
||||||
|
App::App(int argc, char **argv) |
||||||
|
{ |
||||||
|
signal(SIGINT, App::handle_signal); |
||||||
|
signal(SIGTERM, App::handle_signal); |
||||||
|
} |
||||||
|
|
||||||
|
int App::exec() |
||||||
|
{ |
||||||
|
nxl::AutoStore autostore; |
||||||
|
autostore.run(); |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
void App::handle_signal(int signum) |
||||||
|
{ |
||||||
|
std::cout << "\nCaught signal " << signum << ". Graceful shutdown." << std::endl; |
||||||
|
exit(signum); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include <csignal> |
||||||
|
|
||||||
|
namespace nxl |
||||||
|
{ |
||||||
|
class App |
||||||
|
{ |
||||||
|
public: |
||||||
|
App(int argc, char **argv); |
||||||
|
int exec(); |
||||||
|
|
||||||
|
private: |
||||||
|
static void handle_signal(int signum); |
||||||
|
}; |
||||||
|
} |
||||||
@ -1,8 +1,10 @@ |
|||||||
|
#include "App.h" |
||||||
#include "Version.h" |
#include "Version.h" |
||||||
#include <iostream> |
#include <iostream> |
||||||
|
|
||||||
int main() |
int main(int argc, char **argv) |
||||||
{ |
{ |
||||||
std::cout << "AutoStore v" << nxl::getVersionString() << std::endl; |
std::cout << "AutoStore v" << nxl::getVersionString() << std::endl; |
||||||
return 0; |
nxl::App app(argc, argv); |
||||||
|
return app.exec(); |
||||||
} |
} |
||||||
|
|||||||
@ -0,0 +1,26 @@ |
|||||||
|
cmake_minimum_required(VERSION 3.20) |
||||||
|
project(AutoStoreLib) |
||||||
|
set(TARGET_NAME AutoStoreLib) |
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17) |
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON) |
||||||
|
|
||||||
|
|
||||||
|
add_library(${TARGET_NAME} STATIC |
||||||
|
src/AutoStore.cpp |
||||||
|
) |
||||||
|
|
||||||
|
target_include_directories(${TARGET_NAME} |
||||||
|
PUBLIC |
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/include |
||||||
|
) |
||||||
|
|
||||||
|
# Find dependencies |
||||||
|
find_package(httplib CONFIG REQUIRED) |
||||||
|
find_package(Catch2 CONFIG REQUIRED) |
||||||
|
|
||||||
|
target_link_libraries(${TARGET_NAME} |
||||||
|
PUBLIC |
||||||
|
httplib::httplib |
||||||
|
Catch2::Catch2WithMain |
||||||
|
) |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
namespace nxl |
||||||
|
{ |
||||||
|
class AutoStore |
||||||
|
{ |
||||||
|
public: |
||||||
|
AutoStore(); |
||||||
|
void run(); |
||||||
|
}; |
||||||
|
} // namespace nxl
|
||||||
@ -0,0 +1,15 @@ |
|||||||
|
#include "autostore/AutoStore.h" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
namespace nxl |
||||||
|
{ |
||||||
|
AutoStore::AutoStore() |
||||||
|
{ |
||||||
|
std::cout << "AutoStore library initialized." << std::endl; |
||||||
|
} |
||||||
|
|
||||||
|
void AutoStore::run() |
||||||
|
{ |
||||||
|
std::cout << "AutoStore library is running." << std::endl; |
||||||
|
} |
||||||
|
} // namespace nxl
|
||||||
Loading…
Reference in new issue