Grail (C++)  1.2.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
Blueprint.hh
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_BLUEPRINT_H
4 #define GRAIL_BLUEPRINT_H
5 
6 #include <cassert>
7 #include <functional>
8 #include <memory>
9 #include <string>
10 #include <vector>
11 
12 #include "../GrailCore/Blackboard.hh"
13 #include "../GrailCore/EntityBlackboardPair.hh"
14 
15 namespace grail
16 {
17  class AIEntity;
18 
19 namespace utility
20 {
21  template <typename InstanceType, typename ContexType = EntityBlackboardPair, typename DataType = class AIEntity>
30  class Blueprint final
31  {
32  public:
39  Blueprint(std::string name,
40  std::function<std::vector<ContexType>(const DataType&)> contextProducer,
41  std::function<std::unique_ptr<InstanceType>(const ContexType&)> instanceProducer)
42  : name{name}, contextProducer{contextProducer}, instanceProducer{instanceProducer}
43  {
44  }
45 
46  Blueprint(const Blueprint& other) = default;
47  Blueprint(Blueprint&& other) = default;
48 
49  ~Blueprint() = default;
50 
51  Blueprint& operator =(const Blueprint& other) = delete;
52  Blueprint& operator =(Blueprint&& other) = delete;
53 
59  std::vector<ContexType> ProduceContexts(const DataType& data) const
60  {
61  return contextProducer(data);
62  }
63 
69  std::unique_ptr<InstanceType> ProduceInstance(const ContexType& context) const
70  {
71  return instanceProducer(context);
72  }
73 
78  std::string GetName() const { return name; }
79 
80  private:
81  const std::string name = "";
82  const std::function<std::vector<ContexType>(const DataType&)> contextProducer{};
83  const std::function<std::unique_ptr<InstanceType>(const ContexType&)> instanceProducer{};
84  };
85 }
86 }
87 
88 #endif //GRAIL_BLUEPRINT_H
grail::utility::Blueprint::GetName
std::string GetName() const
GetName.
Definition: Blueprint.hh:78
grail::utility::Blueprint::ProduceContexts
std::vector< ContexType > ProduceContexts(const DataType &data) const
ProduceContexts - Uses ContextProducerDelegate provided in constructor to produce collection of Conte...
Definition: Blueprint.hh:59
grail::utility::Blueprint::Blueprint
Blueprint(std::string name, std::function< std::vector< ContexType >(const DataType &)> contextProducer, std::function< std::unique_ptr< InstanceType >(const ContexType &)> instanceProducer)
Blueprint - Contructor.
Definition: Blueprint.hh:39
grail::utility::Blueprint
The Blueprint class - Responsible for producing contexts and instances of data used by UtilityReasone...
Definition: Blueprint.hh:30
grail::utility::Blueprint::ProduceInstance
std::unique_ptr< InstanceType > ProduceInstance(const ContexType &context) const
ProduceInstance - Uses InstanceProducerDelegate provided in constructor to produce instance of Instan...
Definition: Blueprint.hh:69