ActionResult.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef ACTIONRESULT_CPP
  2. #define ACTIONRESULT_CPP
  3. #include <random>
  4. #include "ActionResult.h"
  5. using namespace std;
  6. ActionResult::ActionResult(string _id){
  7. id = _id;
  8. success = false;
  9. }
  10. ActionResult::ActionResult(string _id, bool s){
  11. id = _id;
  12. success = s;
  13. }
  14. ActionResult::ActionResult(string _id, bool s, std::map<string, string> _data){
  15. id = _id;
  16. success = s;
  17. resultData = _data;
  18. }
  19. ActionResult::ActionResult(ActionResult& other){
  20. id = other.id;
  21. success = other.success;
  22. finished = other.finished;
  23. resultData = other.resultData;
  24. }
  25. ActionResult::~ActionResult(){
  26. }
  27. void ActionResult::resolve(bool s){
  28. if(!finished){
  29. finished = true;
  30. success = s;
  31. }
  32. }
  33. SignalEvent* ActionResult::clone(){
  34. return new ActionResult(*this);
  35. }
  36. bool ActionResult::isFinished(){
  37. return finished;
  38. }
  39. bool ActionResult::isSuccess(){
  40. return success;
  41. }
  42. string* ActionResult::getData(string key){
  43. if(resultData.count(key)>0){
  44. return &(resultData[key]);
  45. }
  46. return NULL;
  47. }
  48. string* ActionResult::setData(string key, string val){
  49. string* _val = NULL;
  50. if(resultData.count(key)>0){
  51. _val = &(resultData[key]);
  52. }
  53. resultData[key] = val;
  54. return _val;
  55. }
  56. map<string,string> ActionResult::setDataMap(map<string,string> newData){
  57. map<string,string> temp = resultData;
  58. resultData = newData;
  59. return temp;
  60. }
  61. map<string,string> ActionResult::getDataMap(){
  62. return resultData;
  63. }
  64. #endif