diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..0be2e46 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,40 @@ +# Agent Instructions for MedicalLib + +This document provides instructions for developers and agents working on the MedicalLib C++ project. + +## Project Purpose + +MedicalLib is a C++ library for detailed mathematical simulations of various medical information. Its goal is to provide a robust set of tools for applications that require calculations related to: + +- Heart rate and EKG readings +- Body metrics (e.g., BMI, body fat percentage) +- Physiological responses to injuries +- Other life-requirement math simulations + +## Project Structure + +This project is structured as a software-agnostic C++ library, designed for easy integration into various larger projects, including game engines like Unreal Engine. + +- `/include`: Contains all public header files. + - `/include/MedicalLib`: Headers for the MedicalLib library are placed here to prevent naming conflicts. +- `/src`: Contains the implementation (.cpp) files for the library. +- `/examples`: Contains example code showing how to use the library. +- `/build`: This directory is created by the build scripts and contains the compiled library and example executables. It is not tracked by git. +- `CMakeLists.txt`: The root CMake file for building the project. + +## Building the Project + +To build the project, use the provided build scripts: + +- On Linux or macOS: `./build.sh` +- On Windows: `build.bat` + +The compiled library will be placed in `build/lib`, and the example executable will be in `build/examples/`. + +## Integration with Unreal Engine + +To use this library in an Unreal Engine plugin: + +1. Copy the contents of the `include` directory into your plugin's `ThirdParty/MedicalLib/include` directory. +2. Compile the library for the desired platforms (e.g., Win64, Linux) and copy the compiled library files (e.g., `.lib`, `.so`, `.a`) into your plugin's `ThirdParty/MedicalLib/lib/` directory. +3. In your plugin's `.Build.cs` file, add the necessary paths for the include files and link against the compiled library. diff --git a/CMakeLists.txt b/CMakeLists.txt index 4de9c57..1d8e267 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,19 +2,19 @@ cmake_minimum_required(VERSION 3.10) # Project name -project(MyLibrary) +project(MedicalLib) # Add the library -add_library(MyLibrary SHARED src/Library.cpp) +add_library(MedicalLib SHARED src/MedicalLib.cpp) -# Define MY_LIB_EXPORT, so that __declspec(dllexport) is used -target_compile_definitions(MyLibrary PRIVATE MY_LIB_EXPORT) +# Define MEDICAL_LIB_EXPORT, so that __declspec(dllexport) is used +target_compile_definitions(MedicalLib PRIVATE MEDICAL_LIB_EXPORT) # Public headers -target_include_directories(MyLibrary PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) +target_include_directories(MedicalLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) # Set the output directory for the library -set_target_properties(MyLibrary PROPERTIES +set_target_properties(MedicalLib PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f8f8864..b7f17cb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,4 +2,4 @@ add_executable(Example main.cpp) # Link against the library -target_link_libraries(Example MyLibrary) +target_link_libraries(Example MedicalLib) diff --git a/examples/main.cpp b/examples/main.cpp index 78f09ac..cb20f66 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -1,8 +1,11 @@ #include -#include "Library.h" +#include "MedicalLib/MedicalLib.h" int main() { - int result = add(2, 3); - std::cout << "2 + 3 = " << result << std::endl; + double weight = 70.0; // kg + double height = 1.75; // meters + double bmi = calculateBMI(weight, height); + std::cout << "Weight: " << weight << " kg, Height: " << height << " m" << std::endl; + std::cout << "Calculated BMI: " << bmi << std::endl; return 0; } diff --git a/include/MedicalLib/MedicalLib.h b/include/MedicalLib/MedicalLib.h new file mode 100644 index 0000000..e38ee05 --- /dev/null +++ b/include/MedicalLib/MedicalLib.h @@ -0,0 +1,20 @@ +#pragma once + +// Define MEDICAL_LIB_EXPORT for exporting symbols from the DLL +#if defined(_WIN32) + #if defined(MEDICAL_LIB_EXPORT) + #define MEDICAL_LIB_API __declspec(dllexport) + #else + #define MEDICAL_LIB_API __declspec(dllimport) + #endif +#else + #define MEDICAL_LIB_API +#endif + +/** + * @brief Calculates the Body Mass Index (BMI). + * @param weight_kg The weight in kilograms. + * @param height_m The height in meters. + * @return The calculated BMI. + */ +MEDICAL_LIB_API double calculateBMI(double weight_kg, double height_m); diff --git a/src/Library.cpp b/src/Library.cpp deleted file mode 100644 index aea0f35..0000000 --- a/src/Library.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "Library.h" - -int add(int a, int b) { - return a + b; -} diff --git a/src/Library.h b/src/Library.h deleted file mode 100644 index 89f1463..0000000 --- a/src/Library.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -// Define MY_LIB_EXPORT for exporting symbols from the DLL -#if defined(_WIN32) - #if defined(MY_LIB_EXPORT) - #define MY_LIB_API __declspec(dllexport) - #else - #define MY_LIB_API __declspec(dllimport) - #endif -#else - #define MY_LIB_API -#endif - -// A simple function to be exported -MY_LIB_API int add(int a, int b); diff --git a/src/MedicalLib.cpp b/src/MedicalLib.cpp new file mode 100644 index 0000000..8adf398 --- /dev/null +++ b/src/MedicalLib.cpp @@ -0,0 +1,12 @@ +#include "MedicalLib/MedicalLib.h" +#include + +double calculateBMI(double weight_kg, double height_m) { + if (height_m <= 0) { + throw std::invalid_argument("Height must be positive."); + } + if (weight_kg <= 0) { + throw std::invalid_argument("Weight must be positive."); + } + return weight_kg / (height_m * height_m); +}