|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +cpp-toolbox is a comprehensive C++ library providing reusable components for accelerated development, with strong focus on point cloud processing, concurrency, and utility functions. |
| 8 | + |
| 9 | +## Build Commands |
| 10 | + |
| 11 | +### Primary Development Flow |
| 12 | + |
| 13 | +**Configure with CMake preset:** |
| 14 | +```bash |
| 15 | +# Configure (example for Linux with Clang 21 and TBB) |
| 16 | +cmake -S . -B build/build-linux-clang-21-tbb --preset build-linux-clang-21-tbb |
| 17 | + |
| 18 | +# Build |
| 19 | +cmake --build build/build-linux-clang-21-tbb -j $(nproc) |
| 20 | +``` |
| 21 | + |
| 22 | +**Run tests and benchmarks:** |
| 23 | +```bash |
| 24 | +# Run all tests |
| 25 | +build/build-linux-clang-21-tbb/bin/cpp-toolbox_test |
| 26 | + |
| 27 | +# Run tests with specific tags |
| 28 | +build/build-linux-clang-21-tbb/bin/cpp-toolbox_test "[knn][correspondence]" |
| 29 | + |
| 30 | +# Run benchmarks |
| 31 | +build/build-linux-clang-21-tbb/bin/cpp-toolbox_benchmark --benchmark-samples 10 |
| 32 | + |
| 33 | +# Run benchmarks with specific tags |
| 34 | +build/build-linux-clang-21-tbb/bin/cpp-toolbox_benchmark "[pcl]" --benchmark-samples 10 |
| 35 | +``` |
| 36 | + |
| 37 | +**Development utilities:** |
| 38 | +```bash |
| 39 | +# Format code before committing |
| 40 | +make format |
| 41 | + |
| 42 | +# Run linters |
| 43 | +make lint |
| 44 | + |
| 45 | +# Generate documentation |
| 46 | +make docs |
| 47 | +``` |
| 48 | + |
| 49 | +### Alternative Build Systems |
| 50 | + |
| 51 | +**xmake:** |
| 52 | +```bash |
| 53 | +xmake |
| 54 | +xmake run cpp-toolbox_test |
| 55 | +xmake run cpp-toolbox_benchmark |
| 56 | +``` |
| 57 | + |
| 58 | +## Architecture Overview |
| 59 | + |
| 60 | +The codebase follows a modular architecture with clear separation: |
| 61 | + |
| 62 | +1. **Public API** (`src/include/cpp-toolbox/`): All public headers organized by module |
| 63 | +2. **Implementation** (`src/impl/cpp-toolbox/`): Source files for non-template code |
| 64 | +3. **Header-only implementations** (`*/impl/`): Template implementations in nested impl directories |
| 65 | + |
| 66 | +### Key Modules |
| 67 | + |
| 68 | +- **base/**: Core utilities including thread pools, memory pools, environment helpers |
| 69 | +- **concurrent/**: Parallel algorithms with optional TBB support, lock-free data structures |
| 70 | +- **pcl/**: Point cloud processing components (KNN, features, descriptors, filters, correspondence) |
| 71 | +- **io/**: File I/O including PCD and KITTI format support, data loaders |
| 72 | +- **metrics/**: Metric implementations for evaluation |
| 73 | +- **logger/**: Thread-safe logging framework |
| 74 | + |
| 75 | +### Design Patterns |
| 76 | + |
| 77 | +- CRTP for base classes (e.g., `BaseKNN`, `BaseDescriptorExtractor`) |
| 78 | +- Header-only templates with explicit instantiation where appropriate |
| 79 | +- Factory patterns for extensible components (metrics, correspondence generators) |
| 80 | +- Clear separation of interface and implementation |
| 81 | + |
| 82 | +## Testing Strategy |
| 83 | + |
| 84 | +- All tests compiled into single executable using Catch2 framework |
| 85 | +- All benchmarks compiled into single executable |
| 86 | +- Test structure mirrors source structure |
| 87 | +- Test data located in `test/data/` |
| 88 | +- Use tags to run specific test groups |
| 89 | + |
| 90 | +## Code Style |
| 91 | + |
| 92 | +- **Follow the code style guide in `docs/md/CODE_STYLE.md`** |
| 93 | +- Use clang-format before committing (`make format`) |
| 94 | +- Follow existing patterns in neighboring files |
| 95 | +- Template implementations go in `impl/` subdirectories |
| 96 | +- Use provided type aliases (e.g., `PointCloud`, `KDTree`) |
| 97 | + |
| 98 | +### Key Naming Conventions (from CODE_STYLE.md) |
| 99 | +- Classes, structs, enums, functions, variables: `lower_case` |
| 100 | +- Protected/private members: `m_` prefix + `lower_case` |
| 101 | +- Template parameters: `CamelCase` |
| 102 | +- Macros: `UPPER_CASE` |
| 103 | +- All naming conventions enforced by clang-tidy |
| 104 | + |
| 105 | +## Common Development Tasks |
| 106 | + |
| 107 | +### Adding New PCL Component |
| 108 | +1. Create interface in `src/include/cpp-toolbox/pcl/<category>/` |
| 109 | +2. If templated, add implementation in corresponding `impl/` subdirectory |
| 110 | +3. Add to module's main header (e.g., `features.hpp`, `descriptors.hpp`) |
| 111 | +4. Create unit test in `test/pcl/` |
| 112 | +5. Add benchmark if performance-critical |
| 113 | + |
| 114 | +### Running Specific Tests |
| 115 | +```bash |
| 116 | +# Run tests with specific tag |
| 117 | +build/build-linux-clang-21-tbb/bin/cpp-toolbox_test "[knn]" |
| 118 | + |
| 119 | +# Run multiple test tags |
| 120 | +build/build-linux-clang-21-tbb/bin/cpp-toolbox_test "[knn][correspondence]" |
| 121 | + |
| 122 | +# List all available test cases |
| 123 | +build/build-linux-clang-21-tbb/bin/cpp-toolbox_test --list-tests |
| 124 | +``` |
| 125 | + |
| 126 | +### Debugging Build Issues |
| 127 | +- Check `CMakeUserPresets.json` for correct configuration |
| 128 | +- Ensure dependencies are fetched: `cmake --preset=dev` |
| 129 | +- For TBB support: install system TBB or let CMake fetch it |
| 130 | + |
| 131 | +## Important Notes |
| 132 | + |
| 133 | +- **Use cpp-toolbox utilities wherever possible** - prefer internal implementations over external libraries |
| 134 | +- Thread pool singleton is available via `ThreadPoolSingleton::instance()` |
| 135 | +- PCL components are designed to work with PCL library types but provide own implementations |
| 136 | +- Memory-mapped file support for efficient large file processing |
| 137 | +- Extensive use of concepts and SFINAE for type safety in C++17/20 |
0 commit comments