version  0.0.1
Defines the C++ API for MsPASS
ProcessManager.h
1 #ifndef _PROCESS_MANAGER_H_
2 #define _PROCESS_MANAGER_H_
3 #include <map>
4 #include <vector>
5 #include <boost/serialization/serialization.hpp>
6 #include <boost/serialization/map.hpp>
7 #include <boost/serialization/vector.hpp>
8 #include <boost/archive/text_iarchive.hpp>
9 #include <boost/archive/text_oarchive.hpp>
10 #include <boost/uuid/uuid.hpp>
11 #include <boost/uuid/uuid_generators.hpp>
12 #include <boost/uuid/uuid_io.hpp>
13 #include <boost/uuid/uuid_serialize.hpp>
14 namespace mspass{
15 namespace utility{
44 {
45 public:
51  AlgorithmDefinition() : nm(),myid(),input_type(),output_type() {};
64  AlgorithmDefinition(const std::string name, const std::string typin,
65  const std::string typout, const std::string id)
66  {
67  nm=name;
68  myid=id;
69  input_type=typin;
70  output_type=typout;
71  };
73  {
74  nm=parent.nm;
75  myid=parent.myid;
76  input_type=parent.input_type;
77  output_type=parent.output_type;
78  };
79  std::string name() const
80  {
81  return nm;
82  };
90  std::string id() const
91  {
92  return myid;
93  };
101  void set_id(const std::string id){myid=id;};
102  //void set_name(const string name){nm=name;};
103  AlgorithmDefinition& operator=(const AlgorithmDefinition& parent)
104  {
105  if(this==&parent)
106  {
107  nm=parent.nm;
108  myid=parent.myid;
109  input_type=parent.input_type;
110  output_type=parent.output_type;
111  }
112  return *this;
113  };
114 private:
115  std::string nm;
116  std::string myid;
117  std::string input_type;
118  std::string output_type;
119  friend boost::serialization::access;
120  template<class Archive>
121  void serialize(Archive& ar,const unsigned int version)
122  {
123  ar & nm;
124  ar & myid;
125  };
126 };
128 {
129 public:
130  ProcessManager();
131  ProcessManager(std::string fname);
132  AlgorithmDefinition algorithm(const std::string name,
133  const size_t instance=0) const;
134  std::string jobname() const
135  {
136  return jobnm;
137  };
138  std::string jobid() const
139  {
140  return boost::uuids::to_string(job_uuid);
141  };
153  std::string new_newid()
154  {
155  boost::uuids::uuid id;
156  id=gen();
157  return boost::uuids::to_string(id);
158  }
159 private:
160  std::string jobnm;
161  boost::uuids::uuid job_uuid;
162  boost::uuids::random_generator gen;
163  std::map<std::string,std::vector<AlgorithmDefinition>> algs;
164  friend boost::serialization::access;
165  template<class Archive>
166  void serialize(Archive& ar,const unsigned int version)
167  {
168  ar & jobnm;
169  ar & job_uuid;
170  ar & algs;
171  };
172 };
173 } // end utility namespace
174 } // end mspass namespace encapsulation
175 #endif
Lightweight data structure to completely describe an algorithm.
Definition: ProcessManager.h:44
AlgorithmDefinition()
Definition: ProcessManager.h:51
void set_id(const std::string id)
Definition: ProcessManager.h:101
AlgorithmDefinition(const std::string name, const std::string typin, const std::string typout, const std::string id)
Definition: ProcessManager.h:64
std::string id() const
return the id as a string.
Definition: ProcessManager.h:90
Definition: ProcessManager.h:128
std::string new_newid()
Get a new UUID to define unique job run.
Definition: ProcessManager.h:153