From 707b069ad5d49f4ca43371b252f437db895b8533 Mon Sep 17 00:00:00 2001 From: Fabian Posch Date: Fri, 12 Jan 2024 17:06:20 -0500 Subject: [PATCH] moved database stuff out of normal artifact, created extension for normal artifact --- include/artifact.hpp | 40 ++---------------- include/db_artifact.hpp | 90 +++++++++++++++++++++++++++++++++++++++++ src/artifact.cpp | 8 ---- src/db_artifact.cpp | 34 ++++++++++++++++ 4 files changed, 128 insertions(+), 44 deletions(-) create mode 100644 include/db_artifact.hpp create mode 100644 src/db_artifact.cpp diff --git a/include/artifact.hpp b/include/artifact.hpp index 6723b20..e919e3d 100644 --- a/include/artifact.hpp +++ b/include/artifact.hpp @@ -29,7 +29,6 @@ #include #include #include -#include "db_types.hpp" #include "util.h" namespace pl { @@ -81,25 +80,6 @@ class Artifact { */ Artifact(); - /** - * @brief Construct a new Artifact with a database UUID attached to it. - * - * This should be used when downloading the artifact from the database. - * This ID is actually required when an update in the database is required. - * - * @param id - */ - Artifact(db::uuid_t& id); - - /** - * @brief The ID of this object in the database - * - * This ID will be 0 if this artifact is not tied to anything in the - * database yet, as IDs are assigned on first upload. - * - */ - const db::uuid_t& id = id_; - /** * @brief Get the type of the artifact the object is holding. * @@ -143,11 +123,6 @@ class Artifact { * @return false The artifact cannot be handled by multiple nodes */ bool parallelizable() { return false; }; - - protected: - - db::uuid_t id_; - }; @@ -177,7 +152,7 @@ class ActArtifact: public Artifact { * * @return ArtifactType Will return the ACT artifact type. */ - constexpr ArtifactType get_type() override { return ArtifactType::ACT; }; + ArtifactType get_type() override { return ArtifactType::ACT; }; /** @@ -215,12 +190,6 @@ class SimConfigArtifact: public Artifact { public: SimConfigArtifact(); - SimConfigArtifact(db::uuid_t& id, db::uuid_t& design); - - /** - * @brief The UUID of the design this simulation uses - */ - const db::uuid_t& design = design_; /** * @brief Get the content of the artifact @@ -243,7 +212,7 @@ class SimConfigArtifact: public Artifact { * * @return ArtifactType Will return the SIM_CONFIG artifact type. */ - constexpr ArtifactType get_type() override { return ArtifactType::SIM_CONFIG; }; + ArtifactType get_type() override { return ArtifactType::SIM_CONFIG; }; /** @@ -273,7 +242,6 @@ class SimConfigArtifact: public Artifact { private: std::vector testcases; - db::uuid_t design_; }; /** Reference to a signal in an ACT design */ @@ -306,7 +274,7 @@ class SignalListArtifact: public Artifact { * * @return ArtifactType Will return the SIGLIST artifact type. */ - constexpr ArtifactType get_type() override { return ArtifactType::SIGLIST; }; + ArtifactType get_type() override { return ArtifactType::SIGLIST; }; /** @@ -348,7 +316,7 @@ class SimOutputArtifact: public Artifact { * * @return ArtifactType Will return the SIM_OUTPUT artifact type. */ - constexpr ArtifactType get_type() override { return ArtifactType::SIM_OUTPUT; }; + ArtifactType get_type() override { return ArtifactType::SIM_OUTPUT; }; /** diff --git a/include/db_artifact.hpp b/include/db_artifact.hpp new file mode 100644 index 0000000..8ea02d7 --- /dev/null +++ b/include/db_artifact.hpp @@ -0,0 +1,90 @@ + +/************************************************************************* + * + * Copyright (c) 2023 Fabian Posch + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + ************************************************************************** + */ + +#ifndef __DB_ARTIFACT__ +#define __DB_ARTIFACT__ + +/** + * @brief Data used for a partial artifact from the database + * + * Don't let this confuse you. This is the additional data one would get when + * pulling a (partial) artifact from the database. + * + * Database information is intentionally kept out of the artifact library, since this + * is not needed for local artifact processing (especially in the deploy tool). + * + * Since an agent might have special requirements in regards to additional information, + * no specific implementation is provided by this library. + * + * Combinations of specific artifact types should therefor implemented locally. + * This is just the minimal cross-section of what an agent will have to deal with. + * + */ + +#include "db_types.hpp" + +class DBArtifact { + + public: + + /** + * @brief Construct a new Artifact with a database UUID attached to it. + * + * This should be used when downloading the artifact from the database. + * This ID is actually required when an update in the database is required. + * + * @param id + */ + DBArtifact(const db::uuid_t& id, const db::uuid_t& source_pass, const db::uuid_t& target_artifact); + + /** + * @brief The ID of this object in the database + * + * The ID should be auto-generated when this task is fetched from the database. + * It is generated automatically by said database. + * + * The new partial artifact must be generated immediately to indicate someone + * working on this. + * + */ + const db::uuid_t& id = id_; + + /** + * @brief The ID of the pass in the database which created this object + */ + const db::uuid_t& source_pass = source_pass_; + + /** + * @brief The artifact, which this partial artifact is a part of + */ + const db::uuid_t& target_artifact = target_artifact_; + + protected: + + db::uuid_t id_; + db::uuid_t source_pass_; + db::uuid_t target_artifact_; + +}; + +#endif \ No newline at end of file diff --git a/src/artifact.cpp b/src/artifact.cpp index 9a741dd..cdc31d8 100644 --- a/src/artifact.cpp +++ b/src/artifact.cpp @@ -28,20 +28,12 @@ namespace pl { Artifact::Artifact() {} -Artifact::Artifact(db::uuid_t& id) { - this->id_ = id; -} - void SimConfigArtifact::add_testcase(testcase_t testcase) { this->testcases.emplace_back(testcase); } SimConfigArtifact::SimConfigArtifact() {} -SimConfigArtifact::SimConfigArtifact(db::uuid_t& id, db::uuid_t& design) : Artifact(id) { - this->design_ = design; -} - void SignalListArtifact::add_signal(signal_t signal) { this->signals.emplace_back(signal); } diff --git a/src/db_artifact.cpp b/src/db_artifact.cpp new file mode 100644 index 0000000..a39a77d --- /dev/null +++ b/src/db_artifact.cpp @@ -0,0 +1,34 @@ + +/************************************************************************* + * + * Copyright (c) 2023 Fabian Posch + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + ************************************************************************** + */ + +#include "db_artifact.hpp" + +DBArtifact::DBArtifact( + const db::uuid_t& id, + const db::uuid_t& source_pass, + const db::uuid_t& target_artifact +) { + this->id_ = id; + this->source_pass_ = source_pass; + this->target_artifact_ = target_artifact; +}