1#ifndef _PROCESSING_HISTORY_H_
2#define _PROCESSING_HISTORY_H_
3#include "mspass/utility/ErrorLogger.h"
4#include <boost/archive/text_iarchive.hpp>
5#include <boost/archive/text_oarchive.hpp>
6#include <boost/serialization/map.hpp>
7#include <boost/serialization/serialization.hpp>
8#include <boost/uuid/uuid.hpp>
9#include <boost/uuid/uuid_generators.hpp>
10#include <boost/uuid/uuid_io.hpp>
11#include <boost/uuid/uuid_serialize.hpp>
24enum class ProcessingStatus { RAW, ORIGIN, VOLATILE, SAVED, UNDEFINED };
33enum class AtomicType { SEISMOGRAM, TIMESERIES, UNDEFINED };
53const std::string SAVED_ID_KEY(
"NODEDATA_AT_SAVE");
80 std::string jobid()
const {
return jid; };
81 void set_jobid(
const std::string &newjid) { jid = newjid; };
82 std::string jobname()
const {
return jnm; };
83 void set_jobname(
const std::string jobname) { jnm = jobname; };
84 BasicProcessingHistory &operator=(
const BasicProcessingHistory &parent) {
85 if (
this != (&parent)) {
97 friend boost::serialization::access;
98 template <
class Archive>
99 void serialize(Archive &ar,
const unsigned int version) {
116 mspass::utility::ProcessingStatus
status;
120 mspass::utility::AtomicType
type;
148 bool operator==(
const NodeData &other);
149 bool operator!=(
const NodeData &other);
152 friend boost::serialization::access;
153 template <
class Archive>
154 void serialize(Archive &ar,
const unsigned int version) {
323 void set_as_origin(
const std::string alg,
const std::string algid,
324 const std::string uuid,
const AtomicType typ,
325 bool define_as_raw =
false);
375 const AtomicType typ,
376 const std::vector<ProcessingHistory *> parents,
377 const bool create_newid =
true);
429 void accumulate(
const std::string alg,
const std::string algid,
481 new_map(
const std::string alg,
const std::string algid,
const AtomicType typ,
482 const ProcessingStatus newstatus = ProcessingStatus::VOLATILE);
512 new_map(
const std::string alg,
const std::string algid,
const AtomicType typ,
514 const ProcessingStatus newstatus = ProcessingStatus::VOLATILE);
551 std::string
map_as_saved(
const std::string alg,
const std::string algid,
552 const AtomicType typ);
561 std::multimap<std::string, mspass::utility::NodeData>
get_nodes()
const;
571 int stage()
const {
return current_stage; };
573 ProcessingStatus
status()
const {
return current_status; };
579 std::string
id()
const {
return current_id; };
582 std::pair<std::string, std::string> result(algorithm, algid);
637 std::list<mspass::utility::NodeData>
638 inputs(
const std::string id_to_find)
const;
650 std::multimap<std::string, mspass::utility::NodeData> nodes;
657 ProcessingStatus current_status;
659 std::string current_id;
662 std::string algorithm;
665 friend boost::serialization::access;
666 template <
class Archive>
667 void serialize(Archive &ar,
const unsigned int version) {
668 ar &boost::serialization::base_object<BasicProcessingHistory>(*
this);
696template <
typename Tdata>
697void append_input(
const Tdata &d, ProcessingHistory &his) {
699 const ProcessingHistory *ptr =
dynamic_cast<const ProcessingHistory *
>(&d);
700 his.add_one_input(*ptr);
720std::list<std::tuple<int, std::string, std::string>>
721algorithm_history(
const ProcessingHistory &h);
741std::list<std::string> algorithm_outputs(
const ProcessingHistory &h,
742 const std::string alg,
743 const std::string algid);
Definition ProcessingHistory.h:56
virtual size_t number_of_stages()
Definition ProcessingHistory.h:79
Container to hold error logs for a data object.
Definition ErrorLogger.h:60
Holds properties of data used as input to algorithm that created this object.
Definition ProcessingHistory.h:113
std::string algorithm
Name of algorithm algorithm applied at this stage.
Definition ProcessingHistory.h:132
std::string uuid
Definition ProcessingHistory.h:118
mspass::utility::ProcessingStatus status
Definition ProcessingHistory.h:116
int stage
Definition ProcessingHistory.h:123
std::string algid
Definition ProcessingHistory.h:142
mspass::utility::AtomicType type
Definition ProcessingHistory.h:120
Lightweight class to preserve procesing chain of atomic objects.
Definition ProcessingHistory.h:226
size_t number_of_stages() override
Return number of processing stages that have been applied to this object.
Definition ProcessingHistory.cc:139
void set_as_origin(const std::string alg, const std::string algid, const std::string uuid, const AtomicType typ, bool define_as_raw=false)
Definition ProcessingHistory.cc:149
NodeData current_nodedata() const
Definition ProcessingHistory.cc:659
ProcessingStatus status() const
Definition ProcessingHistory.h:573
ProcessingHistory(const std::string jobnm, const std::string jid)
bool is_saved() const
Definition ProcessingHistory.cc:133
void clear()
Definition ProcessingHistory.cc:631
bool is_raw() const
Definition ProcessingHistory.cc:114
bool is_origin() const
Definition ProcessingHistory.cc:120
void merge(const ProcessingHistory &data_to_add)
Merge the history nodes from another.
Definition ProcessingHistory.cc:439
std::multimap< std::string, mspass::utility::NodeData > get_nodes() const
Definition ProcessingHistory.cc:612
void add_many_inputs(const std::vector< ProcessingHistory * > &d)
Define several data objects as inputs.
Definition ProcessingHistory.cc:304
std::string new_map(const std::string alg, const std::string algid, const AtomicType typ, const ProcessingStatus newstatus=ProcessingStatus::VOLATILE)
Define this algorithm as a one-to-one map of same type data.
ProcessingHistory()
Definition ProcessingHistory.cc:82
int number_inputs() const
Definition ProcessingHistory.cc:648
std::pair< std::string, std::string > created_by() const
Definition ProcessingHistory.h:581
bool is_volatile() const
Definition ProcessingHistory.cc:127
bool is_empty() const
Definition ProcessingHistory.cc:109
int number_inputs(const std::string uuidstr) const
std::string new_ensemble_process(const std::string alg, const std::string algid, const AtomicType typ, const std::vector< ProcessingHistory * > parents, const bool create_newid=true)
Definition ProcessingHistory.cc:172
std::string newid()
Definition ProcessingHistory.cc:651
std::string map_as_saved(const std::string alg, const std::string algid, const AtomicType typ)
Prepare the current data for saving.
Definition ProcessingHistory.cc:395
ProcessingHistory & operator=(const ProcessingHistory &parent)
Definition ProcessingHistory.cc:687
void add_one_input(const ProcessingHistory &data_to_add)
Add one datum as an input for current data.
Definition ProcessingHistory.cc:263
std::string id() const
Definition ProcessingHistory.h:579
std::string new_map(const std::string alg, const std::string algid, const AtomicType typ, const ProcessingHistory &data_to_clone, const ProcessingStatus newstatus=ProcessingStatus::VOLATILE)
Define this algorithm as a one-to-one map.
void set_id(const std::string newid)
Definition ProcessingHistory.cc:658
std::list< mspass::utility::NodeData > inputs(const std::string id_to_find) const
Return a list of data that define the inputs to a give uuids.
Definition ProcessingHistory.cc:670
std::string clean_accumulate_uuids()
Clean up inconsistent uuids that can be produced by reduce.
Definition ProcessingHistory.cc:546
void accumulate(const std::string alg, const std::string algid, const AtomicType typ, const ProcessingHistory &newinput)
Method to use with a spark reduce algorithm.
Definition ProcessingHistory.cc:474
int stage() const
Definition ProcessingHistory.h:571