(C++)  1.1.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
Blueprint.hh
1 #ifndef GRAIL_PREFAB_H
2 #define GRAIL_PREFAB_H
3 
4 #include <vector>
5 #include <memory>
6 #include <cassert>
7 #include <functional>
8 #include <string>
9 
10 #include "../GrailCore/Blackboard.hh"
11 #include "../GrailEvaluators/EntityBlackboardPair.hh"
12 
13 namespace grail
14 {
15  class AIEntity;
16 
17 namespace utility
18 {
19  template <typename InstanceType, typename ContexType = EntityBlackboardPair, typename DataType = class AIEntity>
28  class Blueprint final
29  {
30  public:
37  Blueprint(std::string name,
38  std::function<std::vector<ContexType>(const DataType&)> contextProducer,
39  std::function<std::unique_ptr<InstanceType>(const ContexType&)> instanceProducer)
40  : name{name}, contextProducer{contextProducer}, instanceProducer{instanceProducer}
41  {
42  }
43 
44  Blueprint(const Blueprint& other) = default;
45  Blueprint(Blueprint&& other) = default;
46 
47  ~Blueprint() = default;
48 
49  Blueprint& operator = (const Blueprint& other) = delete;
50  Blueprint& operator = (Blueprint&& other) = delete;
51 
57  std::vector<ContexType> ProduceContexts(const DataType& data) const
58  {
59  return contextProducer(data);
60  }
61 
67  std::unique_ptr<InstanceType> ProduceInstance(const ContexType& context) const
68  {
69  return instanceProducer(context);
70  }
71 
76  std::string GetName() const { return name; }
77 
78  private:
79  const std::string name = "";
80  const std::function<std::vector<ContexType>(const DataType&)> contextProducer{};
81  const std::function<std::unique_ptr<InstanceType>(const ContexType&)> instanceProducer{};
82  };
83 }
84 }
85 #endif //GRAIL_PREFAB_H
The Blueprint class - Responsible for producing contexts and instances of data used by UtilityReasone...
Definition: Blueprint.hh:29
std::vector< ContexType > ProduceContexts(const DataType &data) const
ProduceContexts - Uses ContextProducerDelegate provided in constructor to produce collection of Conte...
Definition: Blueprint.hh:57
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:37
std::string GetName() const
GetName.
Definition: Blueprint.hh:76
std::unique_ptr< InstanceType > ProduceInstance(const ContexType &context) const
ProduceInstance - Uses InstanceProducerDelegate provided in constructor to produce instance of Instan...
Definition: Blueprint.hh:67