Skip to content

Commit 7c6f3b6

Browse files
Copilotradzevich
andauthored
Move main.cpp to examples folder for better library structure
* Initial plan * Move main.cpp to examples/basic folder and ensure library usability Co-authored-by: radzevich <16370355+radzevich@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: radzevich <16370355+radzevich@users.noreply.github.com>
1 parent b49f24c commit 7c6f3b6

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
1919
if(IOC_BUILD_EXAMPLES)
2020
add_subdirectory(examples/dao)
2121
add_subdirectory(examples/services)
22+
add_subdirectory(examples/basic)
2223

23-
add_executable(IOC_example main.cpp
24+
add_executable(IOC_example examples/basic/main.cpp
2425
examples/domain/employee.cpp examples/domain/employee.h
2526
examples/domain/department.cpp examples/domain/department.h
2627
examples/utils/enumerable.cpp examples/utils/enumerable.h

examples/basic/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.24.1)
2+
project(IOC)
3+
4+
set(CMAKE_CXX_STANDARD 20)
5+
6+
# This is a placeholder CMakeLists.txt for the basic example
7+
# The main.cpp example is built in the root CMakeLists.txt

examples/basic/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Basic Example
2+
3+
This directory contains a simple example demonstrating the usage of the IOC library.
4+
5+
## Files
6+
7+
- `main.cpp` - Basic example code showing how to use the IOC dependency injection system
8+
- `CMakeLists.txt` - Build configuration (placeholder, the example is built from the root CMakeLists.txt)
9+
10+
## Running the Example
11+
12+
To build and run this example:
13+
14+
1. From the repository root, build with examples enabled:
15+
```bash
16+
mkdir build && cd build
17+
cmake .. -DIOC_BUILD_EXAMPLES=ON
18+
make
19+
```
20+
21+
2. Run the example:
22+
```bash
23+
./IOC_example
24+
```
25+
26+
The example demonstrates the dependency injection container managing employee and department services with logging and database access.

main.cpp renamed to examples/basic/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "examples/service.h"
1+
#include "../service.h"
22

33
class Automobile {
44
public:

0 commit comments

Comments
 (0)