From be43f965765f83d59748f962219e015ec480d188 Mon Sep 17 00:00:00 2001 From: Valerio Pastore Date: Thu, 11 Jan 2024 20:29:32 +0100 Subject: [PATCH 1/3] adding doxygen --- include/File_Archiver.h | 67 +++++++++++++++++++++++------------------ src/File_Archiver.cpp | 3 -- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/include/File_Archiver.h b/include/File_Archiver.h index b598beb..769f7f3 100755 --- a/include/File_Archiver.h +++ b/include/File_Archiver.h @@ -5,29 +5,34 @@ #include #include +/** + * @brief The namespace inaf::oasbo::Archivers contains classes related to file archiving. + */ namespace inaf::oasbo::Archivers { +/** + * @brief The FileArchiver class is a derived class of BaseArchiver and provides functionality for archiving packets into files. + */ class FileArchiver: public BaseArchiver { protected: - std::ofstream *myfile = nullptr; - bool _open; - std::string computeFileName(std::string fileName); - std::string resolveEnvVar(std::string path); - FileArchiver(std::string dest); - FileArchiver(std::string parent, std::string dest); - FileArchiver(); + std::ofstream *myfile = nullptr; /**< Pointer to the output file stream. */ + bool _open; /**< Flag indicating if the file is open. */ + std::string computeFileName(std::string fileName); /**< Computes the file name based on the given file name. */ + std::string resolveEnvVar(std::string path); /**< Resolves environment variables in the given path. */ + FileArchiver(std::string dest); /**< Constructs a FileArchiver object with the given destination. */ + FileArchiver(std::string parent, std::string dest); /**< Constructs a FileArchiver object with the given parent and destination. */ + FileArchiver(); /**< Default constructor for FileArchiver. */ public: - std::string parentPath; + std::string parentPath; /**< The parent path of the file. */ - int write(PacketLib::BasePacket&) override; - int write(PacketLib::BasePacket&, std::string dest) override; + int write(PacketLib::BasePacket&) override; /**< Writes the given packet to the file. */ + int write(PacketLib::BasePacket&, std::string dest) override; /**< Writes the given packet to the specified destination. */ - int close() override; - int open() override; - bool is_open() override; - void setDest(std::string) override; - void updateDest() override; - std::string getDest() override; + int close() override; /**< Closes the file. */ + int open() override; /**< Opens the file. */ + bool is_open() override; /**< Checks if the file is open. */ + void setDest(std::string) override; /**< Sets the file destination of the packets. */ + std::string getDest() override; /**< Gets the destination. */ ~FileArchiver() { close(); } @@ -36,28 +41,30 @@ public: }; - +/** + * @brief The FileArchiverBuilder class is responsible for building FileArchiver objects. + */ class FileArchiverBuilder { protected: - FileArchiver *arch; + FileArchiver *arch; /**< Pointer to the FileArchiver object being built. */ public: - std::string config_target { "filearchiver" }; - std::string file_name_key { "file_name" }; - std::string archive_path_key { "archive_path" }; + std::string config_target { "filearchiver" }; /**< The configuration target for the FileArchiver. */ + std::string file_name_key { "file_name" }; /**< The key for the file name configuration. */ + std::string archive_path_key { "archive_path" }; /**< The key for the archive path configuration. */ - FileArchiverBuilder(); - FileArchiverBuilder(std::string dest); - FileArchiverBuilder(std::string parent, std::string dest); + FileArchiverBuilder(); /**< Default constructor for FileArchiverBuilder. */ + FileArchiverBuilder(std::string dest); /**< Constructs a FileArchiverBuilder object with the given destination. */ + FileArchiverBuilder(std::string parent, std::string dest); /**< Constructs a FileArchiverBuilder object with the given parent and destination. */ ~FileArchiverBuilder(); - void reset(); + void reset(); /**< Resets the FileArchiverBuilder object. */ - FileArchiverBuilder* configFrom(Configurators::BaseConfigurator &conf); + FileArchiverBuilder* configFrom(Configurators::BaseConfigurator &conf); /**< Configures the FileArchiverBuilder from the given configurator. */ - FileArchiverBuilder* setParent(std::string parent); + FileArchiverBuilder* setParent(std::string parent); /**< Sets the parent path for the FileArchiver. */ - FileArchiverBuilder* setDest(std::string dest); + FileArchiverBuilder* setDest(std::string dest); /**< Sets the destination for the FileArchiver. */ - FileArchiver* getArchiver(); + FileArchiver* getArchiver(); /**< Gets the built FileArchiver object. */ }; -} +} \ No newline at end of file diff --git a/src/File_Archiver.cpp b/src/File_Archiver.cpp index e8a86d2..37dad64 100755 --- a/src/File_Archiver.cpp +++ b/src/File_Archiver.cpp @@ -129,6 +129,3 @@ std::string FileArchiver::resolveEnvVar(std::string path) { return path; } -void FileArchiver::updateDest() { - -} -- GitLab From cfcde391f1c514ddc65d1383689378ebad299441 Mon Sep 17 00:00:00 2001 From: valerio pastore Date: Thu, 11 Jan 2024 20:47:42 +0100 Subject: [PATCH 2/3] . --- deps/Base-DAQ | 2 +- include/File_Archiver.h | 7 +++---- src/Builder.cpp | 7 ++++--- src/File_Archiver.cpp | 25 +++++++++++-------------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/deps/Base-DAQ b/deps/Base-DAQ index 8a0ea2d..e1983e5 160000 --- a/deps/Base-DAQ +++ b/deps/Base-DAQ @@ -1 +1 @@ -Subproject commit 8a0ea2d0e699863df5fe1c91caf2d7b0855957be +Subproject commit e1983e5655deebb48c56018c8414f85f204137c8 diff --git a/include/File_Archiver.h b/include/File_Archiver.h index 769f7f3..2fbb4c0 100755 --- a/include/File_Archiver.h +++ b/include/File_Archiver.h @@ -1,4 +1,3 @@ - #pragma once #include @@ -25,8 +24,8 @@ protected: public: std::string parentPath; /**< The parent path of the file. */ - int write(PacketLib::BasePacket&) override; /**< Writes the given packet to the file. */ - int write(PacketLib::BasePacket&, std::string dest) override; /**< Writes the given packet to the specified destination. */ + int write(Packets::BasePacket&) override; /**< Writes the given packet to the file. */ + int write(Packets::BasePacket&, std::string dest) override; /**< Writes the given packet to the specified destination. */ int close() override; /**< Closes the file. */ int open() override; /**< Opens the file. */ @@ -67,4 +66,4 @@ public: FileArchiver* getArchiver(); /**< Gets the built FileArchiver object. */ }; -} \ No newline at end of file +} diff --git a/src/Builder.cpp b/src/Builder.cpp index 89d1a5a..b79d57b 100644 --- a/src/Builder.cpp +++ b/src/Builder.cpp @@ -19,15 +19,16 @@ void FileArchiverBuilder::reset() { this->arch = new FileArchiver(); } -FileArchiverBuilder* FileArchiverBuilder::configFrom(Configurators::BaseConfigurator &conf) { +FileArchiverBuilder* FileArchiverBuilder::configFrom( + Configurators::BaseConfigurator &conf) { conf.readConfigFromSource(config_target); std::map params = conf.getConfig(); - std::string key = config_target+"_"+archive_path_key; + std::string key = config_target + "_" + archive_path_key; if (params.count(key) > 0) arch->parentPath = params[key]; - key = config_target+"_"+file_name_key; + key = config_target + "_" + file_name_key; if (params.count(key) > 0) arch->setDest(params[key]); return this; diff --git a/src/File_Archiver.cpp b/src/File_Archiver.cpp index 37dad64..bbf7241 100755 --- a/src/File_Archiver.cpp +++ b/src/File_Archiver.cpp @@ -11,25 +11,24 @@ using namespace inaf::oasbo::Archivers; #endif FileArchiver::FileArchiver(std::string parent, std::string dest) : - _open(false), parentPath(parent){ - std::string filename = computeFileName(parent+"/"+dest).append(".raw"); + _open(false), parentPath(parent) { + std::string filename = computeFileName(parent + "/" + dest).append(".raw"); this->dest = filename; } FileArchiver::FileArchiver(std::string dest) : - FileArchiver(FILEARCH_CONFIG, - dest) { + FileArchiver(FILEARCH_CONFIG, dest) { } FileArchiver::FileArchiver() : - FileArchiver(FILEARCH_CONFIG, - ".tmp") { + FileArchiver(FILEARCH_CONFIG, ".tmp") { } -int FileArchiver::write(PacketLib::BasePacket &pack) { +int FileArchiver::write(Packets::BasePacket &pack) { if (myfile == nullptr || !myfile->is_open()) { - time_t now = time(nullptr); - std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") <<"]\t[File Archiver]\t" << " File not opened" << std::endl; + time_t now = time(nullptr); + std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") + << "]\t[File Archiver]\t" << " File not opened" << std::endl; return -1; } myfile->write((char*) pack.getPointerToMemory(), @@ -37,7 +36,7 @@ int FileArchiver::write(PacketLib::BasePacket &pack) { return 1; } -int FileArchiver::write(PacketLib::BasePacket &pack, std::string dest) { +int FileArchiver::write(Packets::BasePacket &pack, std::string dest) { namespace fs = std::filesystem; dest = resolveEnvVar(dest); fs::path dest_path(dest); @@ -57,7 +56,7 @@ int FileArchiver::open() { if (myfile != nullptr) delete myfile; this->myfile = new std::ofstream(this->dest, std::ios::binary); - if(myfile->good()){ + if (myfile->good()) { _open = true; } return _open; @@ -73,7 +72,6 @@ int FileArchiver::close() { return 1; } - bool FileArchiver::is_open() { return _open; } @@ -83,7 +81,7 @@ std::string FileArchiver::getDest() { } void FileArchiver::setDest(std::string dest) { - this->dest = computeFileName(this->parentPath+"/"+dest).append(".raw"); + this->dest = computeFileName(this->parentPath + "/" + dest).append(".raw"); } std::string FileArchiver::computeFileName(std::string dest) { @@ -110,7 +108,6 @@ std::string FileArchiver::computeFileName(std::string dest) { return dest_path.string(); } - std::string FileArchiver::resolveEnvVar(std::string path) { // resolve env var if present if (path.at(0) == '$') { -- GitLab From 1f1094c8ab8558b8810b55573c4f08d1d4699800 Mon Sep 17 00:00:00 2001 From: valerio pastore Date: Fri, 12 Jan 2024 20:17:06 +0100 Subject: [PATCH 3/3] . --- deps/Base-DAQ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/Base-DAQ b/deps/Base-DAQ index e1983e5..a00f9a2 160000 --- a/deps/Base-DAQ +++ b/deps/Base-DAQ @@ -1 +1 @@ -Subproject commit e1983e5655deebb48c56018c8414f85f204137c8 +Subproject commit a00f9a27afbf5f75dab7db2368b9b9b6fcb395e1 -- GitLab