Skip to content

Commit

Permalink
fix TraceFileFactory (#16)
Browse files Browse the repository at this point in the history
Signed-off-by: Timm Ruppert <[email protected]>
  • Loading branch information
TimmRuppert authored Dec 19, 2024
1 parent 8941fbe commit 0117e7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/osi-utilities/tracefile/Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class TraceFileReader {
/**
* @brief Factory class for creating trace file readers based on file extensions
*/
class TraceFileFactory {
class TraceFileReaderFactory {
public:
/**
* @brief Creates a reader instance based on the file extension
Expand Down
29 changes: 15 additions & 14 deletions src/tracefile/reader/Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
#include "osi-utilities/tracefile/reader/TXTHTraceFileReader.h"
#include "osi-utilities/tracefile/reader/MCAPTraceFileReader.h"

class TraceFileFactory {
public:
static std::unique_ptr<osi3::TraceFileReader> createReader(const std::filesystem::path& path) {
if (path.extension().string() == ".osi") {
return std::make_unique<osi3::SingleChannelBinaryTraceFileReader>();
}
if (path.extension().string() == ".mcap") {
return std::make_unique<osi3::MCAPTraceFileReader>();
}
if (path.extension().string() == ".txth") {
return std::make_unique<osi3::TXTHTraceFileReader>();
}
throw std::invalid_argument("Unsupported format: " + path.extension().string());
namespace osi3 {

std::unique_ptr<osi3::TraceFileReader> TraceFileReaderFactory::createReader(const std::filesystem::path& path) {
if (path.extension().string() == ".osi") {
return std::make_unique<osi3::SingleChannelBinaryTraceFileReader>();
}
if (path.extension().string() == ".mcap") {
return std::make_unique<osi3::MCAPTraceFileReader>();
}
};
if (path.extension().string() == ".txth") {
return std::make_unique<osi3::TXTHTraceFileReader>();
}
throw std::invalid_argument("Unsupported format: " + path.extension().string());
}

}

0 comments on commit 0117e7b

Please sign in to comment.