Skip to content

Commit

Permalink
new folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
erikfrojdh committed Mar 7, 2024
1 parent 5286593 commit ef61e62
Show file tree
Hide file tree
Showing 34 changed files with 126 additions and 103 deletions.
50 changes: 27 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,51 +31,55 @@ if(AARE_BUILD_TESTS)
add_subdirectory(tests)
endif()


set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(fmt 6 REQUIRED)


set(CMAKE_BUILD_TYPE "Debug")
# set(CMAKE_BUILD_TYPE "Debug")

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(OPTIMIZATION_FLAGS "-Og -ggdb3 -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
else()
set(OPTIMIZATION_FLAGS "-O3")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# set(OPTIMIZATION_FLAGS "-Og -ggdb3 -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
# else()
# set(OPTIMIZATION_FLAGS "-O3")
# endif()




set(OPTIONAL_FLAGS "")
if(DISABLE_WARNINGS)
set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow -Wformat=2 -Wold-style-cast -Wnon-virtual-dtor -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Woverloaded-virtual -Winline")
endif()

if(USE_SANITIZER)
set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch -fdiagnostics-show-template-tree -fsanitize=address,undefined,pointer-compare -fno-sanitize-recover -D_FORTIFY_SOURCE=2 -fstack-protector -fno-omit-frame-pointer ")
endif()
# set(OPTIONAL_FLAGS "")
# if(DISABLE_WARNINGS)
# set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow -Wformat=2 -Wold-style-cast -Wnon-virtual-dtor -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Woverloaded-virtual -Winline")
# endif()

# if(USE_SANITIZER)
# set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch -fdiagnostics-show-template-tree -fsanitize=address,undefined,pointer-compare -fno-sanitize-recover -D_FORTIFY_SOURCE=2 -fstack-protector -fno-omit-frame-pointer ")
# endif()


set(SUPPRESSED_WARNINGS "-Wno-return-type")

set(CMAKE_CXX_FLAGS "${OPTIMIZATION_FLAGS} ${SUPPRESSED_WARNINGS}")
# set(SUPPRESSED_WARNINGS "-Wno-return-type")

# set(CMAKE_CXX_FLAGS "${OPTIMIZATION_FLAGS} ${SUPPRESSED_WARNINGS}")

# if(USE_PYTHON)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
# endif(USE_PYTHON)


if(USE_PYTHON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif(USE_PYTHON)


# include_directories(include)
# add_subdirectory(src)

add_subdirectory(core)
add_subdirectory(file_io)

include_directories(include)
add_subdirectory(src)


add_library(aare INTERFACE)
target_link_libraries(aare INTERFACE common core file_io)
target_link_libraries(aare INTERFACE core file_io)


add_subdirectory(examples)
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@ Data analysis library for PSI hybrid detectors



## Folder structure

| Folder | subfolder | Content |
|----------|---------------|-------------------------------------|
| include/ | aare/ | top level header/s |
| core/ | include/ | public headers for core |
| | src/ | source files and non public headers |

## file_io class diagram
![file_io class diagram](./extra/uml/out/file_io/ClassDiagram.png)
23 changes: 23 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@


set(SourceFiles
${CMAKE_CURRENT_SOURCE_DIR}/src/defs.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Frame.cpp
)

add_library(core STATIC ${SourceFiles})
target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(core PUBLIC fmt::fmt)
set_property(TARGET core PROPERTY POSITION_INDEPENDENT_CODE ON)

if(AARE_BUILD_TESTS)
set(TestSources
${CMAKE_CURRENT_SOURCE_DIR}/src/defs.test.cpp
)
target_sources(tests PRIVATE ${TestSources} )

#Work around to remove, this is not the way to do it =)
# target_include_directories(tests PRIVATE ${CMAKE_SOURCE_DIR}/include/common)
target_link_libraries(tests PRIVATE core)

endif()
2 changes: 1 addition & 1 deletion include/core/Frame.hpp → core/include/aare/Frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdint>
#include <bits/unique_ptr.h>
#include <vector>
#include "common/defs.hpp"
#include "aare/defs.hpp"



Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/core/Frame.cpp → core/src/Frame.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "core/Frame.hpp"
#include "aare/Frame.hpp"
#include <iostream>

template <typename DataType>
Expand Down
2 changes: 1 addition & 1 deletion src/common/defs.cpp → core/src/defs.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "common/defs.hpp"
#include "aare/defs.hpp"

template <> std::string toString(DetectorType type) {
switch (type) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/defs.test.cpp → core/src/defs.test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <catch2/catch_test_macros.hpp>
#include <string>
#include "defs.hpp"
#include "aare/defs.hpp"
TEST_CASE("Enum to string conversion"){
//By the way I don't think the enum string conversions should be in the defs.hpp file
//but let's use this to show a test
Expand Down
2 changes: 1 addition & 1 deletion examples/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Your First C++ Program
#include <iostream>
#include "file_io/FileHandler.hpp"
#include "aare/FileHandler.hpp"

using JFileHandler = FileHandler<DetectorType::Jungfrau,uint16_t>;
using JFile = File<DetectorType::Jungfrau,uint16_t>;
Expand Down
28 changes: 28 additions & 0 deletions file_io/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


set(SourceFiles
${CMAKE_CURRENT_SOURCE_DIR}/src/File.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/FileFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/JsonFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/JsonFileFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/SubFile.cpp
)

add_library(file_io STATIC ${SourceFiles})
target_include_directories(file_io PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(file_io PUBLIC fmt::fmt core nlohmann_json::nlohmann_json)
set_property(TARGET file_io PROPERTY POSITION_INDEPENDENT_CODE ON)


# if(AARE_BUILD_TESTS)
# set(TestSources
# ${CMAKE_CURRENT_SOURCE_DIR}/src/defs.test.cpp
# )
# target_sources(tests PRIVATE ${TestSources} )

# #Work around to remove, this is not the way to do it =)
# # target_include_directories(tests PRIVATE ${CMAKE_SOURCE_DIR}/include/common)
# target_link_libraries(tests PRIVATE file_io)

# endif()
5 changes: 3 additions & 2 deletions include/file_io/File.hpp → file_io/include/aare/File.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "common/defs.hpp"
#include "core/Frame.hpp"
#include "aare/defs.hpp"
#include "aare/Frame.hpp"
#include "SubFile.hpp"

#include <filesystem>
#include <fmt/core.h>
#include <iostream>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <filesystem>
#include "file_io/File.hpp"
#include "aare/File.hpp"

template <DetectorType detector,typename DataType>
class FileFactory{
// Class that will be used to create File objects
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <filesystem>
#include "file_io/FileFactory.hpp"
#include "file_io/File.hpp"
#include "aare/FileFactory.hpp"
#include "aare/File.hpp"

template <DetectorType detector,typename DataType>
class FileHandler{
private:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "file_io/File.hpp"
#include "core/Frame.hpp"
#include "common/defs.hpp"
#include "aare/File.hpp"
#include "aare/Frame.hpp"
#include "aare/defs.hpp"
template <DetectorType detector, typename DataType>
class JsonFile : public File<detector, DataType> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "file_io/FileFactory.hpp"
#include "aare/FileFactory.hpp"
template <DetectorType detector,typename DataType>
class JsonFileFactory: public FileFactory<detector,DataType>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "file_io/File.hpp"
#include "aare/File.hpp"
#include <filesystem>
template<DetectorType detector,typename DataType>
class RawFileFactory{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "common/defs.hpp"
#include "aare/defs.hpp"
#include <cstdint>
#include <filesystem>
#include <variant>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "file_io/File.hpp"
#include "aare/File.hpp"
#include <filesystem>
#include <fmt/core.h>

Expand Down
3 changes: 2 additions & 1 deletion src/file_io/file/File.cpp → file_io/src/File.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "file_io/File.hpp"
#include "aare/File.hpp"

template <DetectorType detector, typename DataType>
File<detector,DataType>::~File<detector,DataType>() {
for (auto& subfile : subfiles) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "file_io/FileFactory.hpp"
#include "file_io/File.hpp"
#include "file_io/JsonFileFactory.hpp"
#include "aare/FileFactory.hpp"
#include "aare/File.hpp"
#include "aare/JsonFileFactory.hpp"
#include <iostream>

template <DetectorType detector, typename DataType>
Expand Down
2 changes: 1 addition & 1 deletion src/file_io/file/JsonFile.cpp → file_io/src/JsonFile.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "file_io/JsonFile.hpp"
#include "aare/JsonFile.hpp"
#include <typeinfo>

template <DetectorType detector, typename DataType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "file_io/JsonFileFactory.hpp"
#include "file_io/JsonFile.hpp"
#include "file_io/SubFile.hpp"
#include "common/defs.hpp"
#include "file_io/helpers.hpp"
#include "aare/JsonFileFactory.hpp"
#include "aare/JsonFile.hpp"
#include "aare/SubFile.hpp"
#include "aare/defs.hpp"
#include "aare/helpers.hpp"
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/file_io/file/SubFile.cpp → file_io/src/SubFile.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "file_io/SubFile.hpp"
#include "aare/SubFile.hpp"
#include <iostream>
// #include <filesystem>

Expand Down
2 changes: 1 addition & 1 deletion src/file_io/helpers.cpp → file_io/src/helpers.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "file_io/helpers.hpp"
#include "aare/helpers.hpp"


bool is_master_file(std::filesystem::path fpath) {
Expand Down
1 change: 1 addition & 0 deletions include/aare/aare.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//This is the top level header to include and what most users will use
3 changes: 3 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pybind11_add_module(_aare src/bindings.cpp)
set_target_properties(_aare PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
)
6 changes: 3 additions & 3 deletions python/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <pybind11/pybind11.h>
#include <string>

#include "common/defs.hpp"
#include "core/Frame.hpp"
#include "file_io/FileHandler.hpp"
#include "aare/defs.hpp"
#include "aare/Frame.hpp"
#include "aare/FileHandler.hpp"

namespace py = pybind11;

Expand Down
1 change: 0 additions & 1 deletion src/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions src/CMakeLists.txt

This file was deleted.

16 changes: 0 additions & 16 deletions src/common/CMakeLists.txt

This file was deleted.

10 changes: 0 additions & 10 deletions src/core/CMakeLists.txt

This file was deleted.

16 changes: 0 additions & 16 deletions src/file_io/CMakeLists.txt

This file was deleted.

Empty file removed src/processing/CMakeLists.txt
Empty file.
1 change: 0 additions & 1 deletion tests/.gitignore

This file was deleted.

0 comments on commit ef61e62

Please sign in to comment.