Project Malmo  0.37.0
MissionEndedXML.h
1 // --------------------------------------------------------------------------------------------------
2 // Copyright (c) 2016 Microsoft Corporation
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5 // associated documentation files (the "Software"), to deal in the Software without restriction,
6 // including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in all copies or
11 // substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14 // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 // --------------------------------------------------------------------------------------------------
19 
20 #ifndef _MISSIONENDEDXML_H_
21 #define _MISSIONENDEDXML_H_
22 
23 // STL:
24 #include <string>
25 #include <vector>
26 
27 // Boost:
28 #include <boost/property_tree/ptree.hpp>
29 
30 #include "RewardXML.h"
31 
32 namespace malmo {
33 
35  public:
36 
37  // MissionResult values
38  static constexpr const char* ENDED = "ENDED";
39  static constexpr const char* PLAYER_DIED = "PLAYER_DIED";
40  static constexpr const char* AGENT_QUIT = "AGENT_QUIT";
41  static constexpr const char* MOD_FAILED_TO_INSTANTIATE_HANDLERS = "MOD_FAILED_TO_INSTANTIATE_HANDLERS";
42  static constexpr const char* MOD_HAS_NO_WORLD_LOADED = "MOD_HAS_NO_WORLD_LOADED";
43  static constexpr const char* MOD_FAILED_TO_CREATE_WORLD = "MOD_FAILED_TO_CREATE_WORLD";
44  static constexpr const char* MOD_HAS_NO_AGENT_AVAILABLE = "MOD_HAS_NO_AGENT_AVAILABLE";
45  static constexpr const char* MOD_SERVER_UNREACHABLE = "MOD_SERVER_UNREACHABLE";
46  static constexpr const char* MOD_SERVER_ABORTED_MISSION = "MOD_SERVER_ABORTED_MISSION";
47  static constexpr const char* MOD_CONNECTION_FAILED = "MOD_CONNECTION_FAILED";
48  static constexpr const char* MOD_CRASHED = "MOD_CRASHED";
49  // MissionResult values end
50 
51  MissionEndedXML(std::string xml_text);
52  std::string toXml() const;
53 
55 
56  VideoDataAttributes() : frames_sent(0) {}
57 
58  std::string frame_type;
59  int frames_sent;
60  boost::optional<int> frames_received;
61  boost::optional<int> frames_written;
62  };
63 
64  const std::string& getStatus() { return status; }
65  const std::string& getHumanReadableStatus() { return human_readable_status; }
66  const RewardXML& getReward() { return reward; }
67 
68  std::vector<VideoDataAttributes>& videoDataAttributes() { return video_data_attributes; }
69 
70  private:
71  boost::optional<std::string> schema_version;
72  std::string status;
73  std::string human_readable_status;
74  bool have_rewards;
75  RewardXML reward;
76  std::vector<VideoDataAttributes> video_data_attributes;
77  };
78 }
79 #endif
Definition: MissionEndedXML.h:34
Definition: MissionEndedXML.h:54