Nhat Anh | a0bada6 | 2022-11-07 23:06:23 +0700 | [diff] [blame] | 1 | #ifndef XAPP_MODEL_SubsequentAction_H |
| 2 | #define XAPP_MODEL_SubsequentAction_H |
| 3 | #include "ModelBase.h" |
| 4 | |
| 5 | namespace xapp { |
| 6 | namespace model { |
| 7 | |
| 8 | struct SubsequentAction: ModelBase { |
| 9 | std::string SubsequentActionType; |
| 10 | std::string TimeToWait; |
| 11 | json validator_schema = R"( |
| 12 | { |
| 13 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 14 | "title": "SubsequentAction", |
| 15 | "properties": { |
| 16 | "SubsequentActionType": { |
| 17 | "description": "Type of Subsequent Action", |
| 18 | "type": "string", |
| 19 | "enum": ["wait", "continue"] |
| 20 | |
| 21 | }, |
| 22 | "TimeToWait": { |
| 23 | "description": "Time to waiting", |
| 24 | "type": "string", |
| 25 | "enum": ["zero", "w1ms", "w2ms", "w5ms", "w10ms", "w20ms", "w30ms", |
| 26 | "w40ms", "w50ms", "w100ms", "w200ms", "w500ms", "w1s", |
| 27 | "w2s", "w5s", "w10s", "w20s", "w60s"] |
| 28 | } |
| 29 | }, |
| 30 | "required": [ |
| 31 | "SubsequentActionType", |
| 32 | "TimeToWait" |
| 33 | ], |
| 34 | "type": "object" |
| 35 | })"_json; |
| 36 | |
| 37 | virtual json get_validator_schema() const { return validator_schema; } |
| 38 | }; |
| 39 | |
| 40 | void from_json(const json& j, SubsequentAction& ref) { |
| 41 | |
| 42 | std::cout << __PRETTY_FUNCTION__ << "\n"; |
| 43 | ref.validate_json(j); |
| 44 | |
| 45 | j.at("SubsequentActionType").get_to(ref.SubsequentActionType); |
| 46 | j.at("TimeToWait").get_to(ref.TimeToWait); |
| 47 | } |
| 48 | |
| 49 | void to_json(json& j, const SubsequentAction& ref) { |
| 50 | |
| 51 | j = json { |
| 52 | {"SubsequentActionType",ref.SubsequentActionType}, |
| 53 | {"TimeToWait", ref.TimeToWait} |
| 54 | }; |
| 55 | } |
| 56 | |
| 57 | } /*model*/ |
| 58 | } /*xapp*/ |
| 59 | #endif /*XAPP_MODEL_SubsequentAction_H*/ |