1 #ifndef __ARC_JOBSTATE_H__
2 #define __ARC_JOBSTATE_H__
34 #define JOBSTATE_TABLE \
35 JOBSTATE_X(ACCEPTED, "Accepted")\
36 JOBSTATE_X(PREPARING, "Preparing")\
37 JOBSTATE_X(SUBMITTING, "Submitting")\
38 JOBSTATE_X(HOLD, "Hold")\
39 JOBSTATE_X(QUEUING, "Queuing")\
40 JOBSTATE_X(RUNNING, "Running")\
41 JOBSTATE_X(FINISHING, "Finishing")\
42 JOBSTATE_X(FINISHED, "Finished")\
43 JOBSTATE_X(KILLED, "Killed")\
44 JOBSTATE_X(FAILED, "Failed")\
45 JOBSTATE_X(DELETED, "Deleted")\
46 JOBSTATE_X(OTHER, "Other")
48 #define JOBSTATE_X(a, b) , a
49 enum StateType { UNDEFINED JOBSTATE_TABLE };
51 static const std::string StateTypeString[];
53 JobState() : ssf(FormatSpecificState), type(UNDEFINED) {}
55 JobState& operator=(
const JobState& js) { type = js.type; state = js.state; ssf = js.ssf;
return *
this; }
57 operator bool()
const {
return type != UNDEFINED; }
58 operator StateType()
const {
return type; }
59 bool operator!()
const {
return type == UNDEFINED; }
60 bool operator==(
const StateType& st)
const {
return type == st; }
61 bool operator!=(
const StateType& st)
const {
return type != st; }
68 bool IsFinished()
const {
return type == FINISHED || type == KILLED || type == FAILED || type == DELETED; }
102 static StateType GetStateType(
const std::string& state);
107 typedef std::string (*SpecificStateFormater)(
const std::string&);
108 SpecificStateFormater ssf;
109 static std::string FormatSpecificState(
const std::string& state) {
return state; }
111 JobState(
const std::string& state, JobState::StateType (*map)(
const std::string&), SpecificStateFormater ssf = FormatSpecificState)
112 : ssf(ssf), state(state), type((*map)(state)) {};
121 typedef JobState::StateType (*JobStateMap)(
const std::string&);
124 #endif // __ARC_JOBSTATE_H__