version  0.0.1
Defines the C++ API for MsPASS
Loading...
Searching...
No Matches
ProcessManager.h
1#ifndef _PROCESS_MANAGER_H_
2#define _PROCESS_MANAGER_H_
3#include <boost/archive/text_iarchive.hpp>
4#include <boost/archive/text_oarchive.hpp>
5#include <boost/serialization/map.hpp>
6#include <boost/serialization/serialization.hpp>
7#include <boost/serialization/vector.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>
12#include <map>
13#include <vector>
14namespace mspass {
15namespace utility {
44public:
50 AlgorithmDefinition() : nm(), myid(), input_type(), output_type() {};
63 AlgorithmDefinition(const std::string name, const std::string typin,
64 const std::string typout, const std::string id) {
65 nm = name;
66 myid = id;
67 input_type = typin;
68 output_type = typout;
69 };
71 nm = parent.nm;
72 myid = parent.myid;
73 input_type = parent.input_type;
74 output_type = parent.output_type;
75 };
76 std::string name() const { return nm; };
84 std::string id() const { return myid; };
92 void set_id(const std::string id) { myid = id; };
93 // void set_name(const string name){nm=name;};
94 AlgorithmDefinition &operator=(const AlgorithmDefinition &parent) {
95 if (this == &parent) {
96 nm = parent.nm;
97 myid = parent.myid;
98 input_type = parent.input_type;
99 output_type = parent.output_type;
100 }
101 return *this;
102 };
103
104private:
105 std::string nm;
106 std::string myid;
107 std::string input_type;
108 std::string output_type;
109 friend boost::serialization::access;
110 template <class Archive>
111 void serialize(Archive &ar, const unsigned int version) {
112 ar & nm;
113 ar & myid;
114 };
115};
117public:
119 ProcessManager(std::string fname);
120 AlgorithmDefinition algorithm(const std::string name,
121 const size_t instance = 0) const;
122 std::string jobname() const { return jobnm; };
123 std::string jobid() const { return boost::uuids::to_string(job_uuid); };
135 std::string new_newid() {
136 boost::uuids::uuid id;
137 id = gen();
138 return boost::uuids::to_string(id);
139 }
140
141private:
142 std::string jobnm;
143 boost::uuids::uuid job_uuid;
144 boost::uuids::random_generator gen;
145 std::map<std::string, std::vector<AlgorithmDefinition>> algs;
146 friend boost::serialization::access;
147 template <class Archive>
148 void serialize(Archive &ar, const unsigned int version) {
149 ar & jobnm;
150 ar & job_uuid;
151 ar & algs;
152 };
153};
154} // namespace utility
155} // namespace mspass
156#endif
Lightweight data structure to completely describe an algorithm.
Definition ProcessManager.h:43
AlgorithmDefinition()
Definition ProcessManager.h:50
void set_id(const std::string id)
Definition ProcessManager.h:92
AlgorithmDefinition(const std::string name, const std::string typin, const std::string typout, const std::string id)
Definition ProcessManager.h:63
std::string id() const
return the id as a string.
Definition ProcessManager.h:84
Definition ProcessManager.h:116
std::string new_newid()
Get a new UUID to define unique job run.
Definition ProcessManager.h:135