Grail (C++)  1.4.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 <functional>
7 #include <memory>
8 #include <string>
9 #include <vector>
10 
11 #include "../GrailCore/Blackboard.hh"
12 #include "../GrailCore/EntityBlackboardPair.hh"
13 
14 namespace grail
15 {
16  class AIEntity;
17 
18 namespace utility
19 {
20  template <typename InstanceType, typename ContexType = EntityBlackboardPair, typename DataType = class AIEntity>
29  class Blueprint final
30  {
31  public:
38  Blueprint(std::string name,
39  std::function<std::vector<ContexType>(const DataType&)> contextProducer,
40  std::function<std::unique_ptr<InstanceType>(const ContexType&)> instanceProducer)
41  : name{name}, contextProducer{contextProducer}, instanceProducer{instanceProducer}
42  {
43  }
44 
45  Blueprint(const Blueprint& other) = default;
46  Blueprint(Blueprint&& other) = default;
47 
48  ~Blueprint() = default;
49 
50  Blueprint& operator =(const Blueprint& other) = delete;
51  Blueprint& operator =(Blueprint&& other) = delete;
52 
58  std::vector<ContexType> ProduceContexts(const DataType& data) const
59  {
60  return contextProducer(data);
61  }
62 
68  std::unique_ptr<InstanceType> ProduceInstance(const ContexType& context) const
69  {
70  return instanceProducer(context);
71  }
72 
77  std::string GetName() const { return name; }
78 
79  private:
80  const std::string name = "";
81  const std::function<std::vector<ContexType>(const DataType&)> contextProducer{};
82  const std::function<std::unique_ptr<InstanceType>(const ContexType&)> instanceProducer{};
83  };
84 }
85 }
86 
87 #endif //GRAIL_BLUEPRINT_H
grail::utility::Blueprint::GetName
std::string GetName() const
GetName.
Definition: Blueprint.hh:77
grail::utility::Blueprint::ProduceContexts
std::vector< ContexType > ProduceContexts(const DataType &data) const
ProduceContexts - Uses ContextProducerDelegate provided in the constructor to produce a collection of...
Definition: Blueprint.hh:58
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:38
grail::utility::Blueprint
The Blueprint class - Responsible for producing contexts and instances of data used by UtilityReasone...
Definition: Blueprint.hh:29
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:68