moved database stuff out of normal artifact, created extension for normal artifact

This commit is contained in:
Fabian Posch 2024-01-12 17:06:20 -05:00
parent 9e1cc9d0e4
commit 707b069ad5
4 changed files with 128 additions and 44 deletions

View file

@ -29,7 +29,6 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <memory> #include <memory>
#include "db_types.hpp"
#include "util.h" #include "util.h"
namespace pl { namespace pl {
@ -81,25 +80,6 @@ class Artifact {
*/ */
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. * @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 * @return false The artifact cannot be handled by multiple nodes
*/ */
bool parallelizable() { return false; }; 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. * @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: public:
SimConfigArtifact(); 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 * @brief Get the content of the artifact
@ -243,7 +212,7 @@ class SimConfigArtifact: public Artifact {
* *
* @return ArtifactType Will return the SIM_CONFIG artifact type. * @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: private:
std::vector<testcase_t> testcases; std::vector<testcase_t> testcases;
db::uuid_t design_;
}; };
/** Reference to a signal in an ACT 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. * @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. * @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; };
/** /**

90
include/db_artifact.hpp Normal file
View file

@ -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

View file

@ -28,20 +28,12 @@ namespace pl {
Artifact::Artifact() {} Artifact::Artifact() {}
Artifact::Artifact(db::uuid_t& id) {
this->id_ = id;
}
void SimConfigArtifact::add_testcase(testcase_t testcase) { void SimConfigArtifact::add_testcase(testcase_t testcase) {
this->testcases.emplace_back(testcase); this->testcases.emplace_back(testcase);
} }
SimConfigArtifact::SimConfigArtifact() {} SimConfigArtifact::SimConfigArtifact() {}
SimConfigArtifact::SimConfigArtifact(db::uuid_t& id, db::uuid_t& design) : Artifact(id) {
this->design_ = design;
}
void SignalListArtifact::add_signal(signal_t signal) { void SignalListArtifact::add_signal(signal_t signal) {
this->signals.emplace_back(signal); this->signals.emplace_back(signal);
} }

34
src/db_artifact.cpp Normal file
View file

@ -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;
}