Grail (C++)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
UtilityEvaluatorSnapshot.h
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_UTILITY_EVALUATOR_SNAPSHOT_H
4 #define GRAIL_UTILITY_EVALUATOR_SNAPSHOT_H
5 
6 #include "EvaluationDebugData.h"
7 #include "Flatbuffers/UtilityEvaluatorSnapshot_generated.h"
8 
9 #include <string>
10 #include <vector>
11 #include <map>
12 
13 namespace YAML
14 {
15  template <typename DataType>
16  struct convert;
17 }
18 
19 namespace grail
20 {
21 namespace data
22 {
27  {
28  friend struct YAML::convert<UtilityEvaluatorSnapshot>;
29  public:
30  UtilityEvaluatorSnapshot() = default;
36  UtilityEvaluatorSnapshot(const std::string& evaluatedObjectName, const std::string& metadata, int rank = 0);
37 
42  void AddEvaluation(EvaluationDebugData&& debugData);
43 
49  unsigned int AddNode(const void* nodePointer);
50 
55  const std::vector<EvaluationDebugData>& GetEvaluations() const;
56 
61  const std::string& GetEvaluatedObjectName() const;
62 
67  const std::string& GetEvaluatedObjectMetadata() const;
68 
73  const int& GetRank() const;
74 
79  const std::map<const void*, unsigned int>& GetNodeMapping() const;
80 
81  private:
82  std::vector<EvaluationDebugData> evaluations{};
83  std::map<const void*, unsigned int> nodeMapping{};
84  unsigned int nextIndex{0};
85  std::string evaluatedObjectName{};
86  std::string evaluatedObjectMetadata{};
87  int rank{0};
88  };
89 
90  flatbuffers::Offset<generated::UtilityEvaluatorSnapshot> Pack(flatbuffers::FlatBufferBuilder& builder, const UtilityEvaluatorSnapshot& snapshot);
91  UtilityEvaluatorSnapshot Unpack(const generated::UtilityEvaluatorSnapshot& snapshot);
92 }
93 }
94 
95 #endif
grail::data::EvaluationDebugData
The EvaluationDebugData class - debug data describing singular evaluator.
Definition: EvaluationDebugData.h:24
grail::data::UtilityEvaluatorSnapshot::GetEvaluatedObjectMetadata
const std::string & GetEvaluatedObjectMetadata() const
GetEvaluatedObjectMetadata.
Definition: UtilityEvaluatorSnapshot.cpp:30
grail::data::UtilityEvaluatorSnapshot::AddNode
unsigned int AddNode(const void *nodePointer)
AddNode - assign index indicating position in debug tree to the given node pointer.
Definition: UtilityEvaluatorSnapshot.cpp:21
grail::data::UtilityEvaluatorSnapshot::GetEvaluatedObjectName
const std::string & GetEvaluatedObjectName() const
GetEvaluatedObjectName.
Definition: UtilityEvaluatorSnapshot.cpp:29
grail::data::UtilityEvaluatorSnapshot::GetNodeMapping
const std::map< const void *, unsigned int > & GetNodeMapping() const
GetNodeMapping.
Definition: UtilityEvaluatorSnapshot.cpp:32
grail::data::UtilityEvaluatorSnapshot::AddEvaluation
void AddEvaluation(EvaluationDebugData &&debugData)
AddEvaluation - add debug data describing singular evaluator node to this snapshot.
Definition: UtilityEvaluatorSnapshot.cpp:16
grail::data::UtilityEvaluatorSnapshot
The UtilityEvaluatorSnapshot class - debug snapshot of whole evaluator tree assigned to evaluated obj...
Definition: UtilityEvaluatorSnapshot.h:26
grail::data::UtilityEvaluatorSnapshot::GetRank
const int & GetRank() const
GetRank.
Definition: UtilityEvaluatorSnapshot.cpp:31
grail::data::UtilityEvaluatorSnapshot::GetEvaluations
const std::vector< EvaluationDebugData > & GetEvaluations() const
GetEvaluations.
Definition: UtilityEvaluatorSnapshot.cpp:28