better file structure for better separation

This commit is contained in:
Bechir
2024-03-06 21:08:52 +01:00
parent 1b7ea707ae
commit 22fb8763be
24 changed files with 29 additions and 43 deletions

View File

@ -72,7 +72,7 @@ set(SUPPRESSED_WARNINGS "-Wno-return-type")
set(CMAKE_CXX_FLAGS "${OPTIONAL_FLAGS} ${OPTIMIZATION_FLAGS} ${SUPPRESSED_WARNINGS}") set(CMAKE_CXX_FLAGS "${OPTIONAL_FLAGS} ${OPTIMIZATION_FLAGS} ${SUPPRESSED_WARNINGS}")
include_directories(include)
add_subdirectory(src) add_subdirectory(src)

View File

@ -1,6 +1,6 @@
// Your First C++ Program // Your First C++ Program
#include <iostream> #include <iostream>
#include <FileHandler.hpp> #include "file_io/FileHandler.hpp"
using JFileHandler = FileHandler<DetectorType::Jungfrau,uint16_t>; using JFileHandler = FileHandler<DetectorType::Jungfrau,uint16_t>;
using JFile = File<DetectorType::Jungfrau,uint16_t>; using JFile = File<DetectorType::Jungfrau,uint16_t>;
@ -19,9 +19,7 @@ void test(JFileHandler* f,int frame_number){
} }
int main() { int main() {
std::filesystem::path fpath("/home/l_bechir/github/aare/data/jungfrau_single_master_0.json"); std::filesystem::path fpath("/home/bb/github/aare/data/jungfrau_single_master_0.json");
auto fileHandler = new JFileHandler (fpath); auto fileHandler = new JFileHandler (fpath);
delete fileHandler; delete fileHandler;
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "defs.hpp" #include "common/defs.hpp"
#include "Frame.hpp" #include "core/Frame.hpp"
#include "SubFile.hpp" #include "SubFile.hpp"
#include <filesystem> #include <filesystem>
#include <fmt/core.h> #include <fmt/core.h>

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <filesystem> #include <filesystem>
#include "File.hpp" #include "file_io/File.hpp"
template <DetectorType detector,typename DataType> template <DetectorType detector,typename DataType>
class FileFactory{ class FileFactory{
// Class that will be used to create File objects // Class that will be used to create File objects

View File

@ -1,6 +1,6 @@
#include <filesystem> #include <filesystem>
#include "FileFactory.hpp" #include "file_io/FileFactory.hpp"
#include "File.hpp" #include "file_io/File.hpp"
template <DetectorType detector,typename DataType> template <DetectorType detector,typename DataType>
class FileHandler{ class FileHandler{
private: private:

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "File.hpp" #include "file_io/File.hpp"
#include "Frame.hpp" #include "core/Frame.hpp"
#include "defs.hpp" #include "common/defs.hpp"
template <DetectorType detector, typename DataType> template <DetectorType detector, typename DataType>
class JsonFile : public File<detector, DataType> { class JsonFile : public File<detector, DataType> {

View File

@ -1,4 +1,4 @@
#include "FileFactory.hpp" #include "file_io/FileFactory.hpp"
template <DetectorType detector,typename DataType> template <DetectorType detector,typename DataType>
class JsonFileFactory: public FileFactory<detector,DataType> class JsonFileFactory: public FileFactory<detector,DataType>
{ {

View File

@ -1,4 +1,4 @@
#include "File.hpp" #include "file_io/File.hpp"
#include <filesystem> #include <filesystem>
template<DetectorType detector,typename DataType> template<DetectorType detector,typename DataType>
class RawFileFactory{ class RawFileFactory{

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "defs.hpp" #include "common/defs.hpp"
#include <cstdint> #include <cstdint>
#include <filesystem> #include <filesystem>
#include <variant> #include <variant>

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "File.hpp" #include "file_io/File.hpp"
#include <filesystem> #include <filesystem>
#include <fmt/core.h> #include <fmt/core.h>

View File

@ -1,7 +1,5 @@
add_library(common "${CMAKE_CURRENT_SOURCE_DIR}/defs.cpp") add_library(common "${CMAKE_CURRENT_SOURCE_DIR}/defs.cpp")
target_include_directories(common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(common PUBLIC fmt::fmt) target_link_libraries(common PUBLIC fmt::fmt)

View File

@ -1,4 +1,4 @@
#include "defs.hpp" #include "common/defs.hpp"
template <> std::string toString(DetectorType type) { template <> std::string toString(DetectorType type) {
switch (type) { switch (type) {

View File

@ -5,8 +5,6 @@
add_library(core "${CMAKE_CURRENT_SOURCE_DIR}/Frame.cpp") add_library(core "${CMAKE_CURRENT_SOURCE_DIR}/Frame.cpp")
target_include_directories(core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(core PUBLIC common) target_link_libraries(core PUBLIC common)

View File

@ -1,4 +1,4 @@
#include "Frame.hpp" #include "core/Frame.hpp"
#include <iostream> #include <iostream>
template <typename DataType> template <typename DataType>

View File

@ -4,7 +4,6 @@ set(FILE_IO_SOURCES "file/File.cpp"
"file/SubFile.cpp" "file/SubFile.cpp"
"file_factory/FileFactory.cpp" "file_factory/FileFactory.cpp"
"file_factory/JsonFileFactory.cpp" "file_factory/JsonFileFactory.cpp"
"file_factory/RawFileFactory.cpp"
"helpers.cpp" "helpers.cpp"
) )
# append ${CMAKE_CURRENT_SOURCE_DIR} to the list of sources using for loop # append ${CMAKE_CURRENT_SOURCE_DIR} to the list of sources using for loop
@ -14,10 +13,4 @@ endforeach()
add_library(file_io ${FILE_IO_SOURCES_WITH_PATH}) add_library(file_io ${FILE_IO_SOURCES_WITH_PATH})
target_include_directories(file_io PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/file")
target_include_directories(file_io PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/file_factory")
target_include_directories(file_io PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(file_io common fmt::fmt core nlohmann_json::nlohmann_json) target_link_libraries(file_io common fmt::fmt core nlohmann_json::nlohmann_json)

View File

@ -1,4 +1,4 @@
#include "File.hpp" #include "file_io/File.hpp"
template <DetectorType detector, typename DataType> template <DetectorType detector, typename DataType>
File<detector,DataType>::~File<detector,DataType>() { File<detector,DataType>::~File<detector,DataType>() {
for (auto& subfile : subfiles) { for (auto& subfile : subfiles) {

View File

@ -1,4 +1,4 @@
#include "JsonFile.hpp" #include "file_io/JsonFile.hpp"
#include <typeinfo> #include <typeinfo>
template <DetectorType detector,typename DataType> template <DetectorType detector,typename DataType>

View File

@ -1,4 +1,4 @@
#include "SubFile.hpp" #include "file_io/SubFile.hpp"
#include <iostream> #include <iostream>
// #include <filesystem> // #include <filesystem>

View File

@ -1,7 +1,6 @@
#include "FileFactory.hpp" #include "file_io/FileFactory.hpp"
#include "File.hpp" #include "file_io/File.hpp"
#include "JsonFileFactory.hpp" #include "file_io/JsonFileFactory.hpp"
#include "RawFileFactory.hpp"
#include <iostream> #include <iostream>
template <DetectorType detector, typename DataType> template <DetectorType detector, typename DataType>

View File

@ -1,8 +1,8 @@
#include "JsonFileFactory.hpp" #include "file_io/JsonFileFactory.hpp"
#include "JsonFile.hpp" #include "file_io/JsonFile.hpp"
#include "SubFile.hpp" #include "file_io/SubFile.hpp"
#include "defs.hpp" #include "common/defs.hpp"
#include "helpers.hpp" #include "file_io/helpers.hpp"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>

View File

@ -1,4 +1,4 @@
#include "helpers.hpp" #include "file_io/helpers.hpp"
bool is_master_file(std::filesystem::path fpath) { bool is_master_file(std::filesystem::path fpath) {