(C++)  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
ObjectIndexBinding.hh
1 #ifndef GRAIL_OBJECT_INDEX_BINDING_H
2 #define GRAIL_OBJECT_INDEX_BINDING_H
3 
4 #include "IPlannerObject.hh"
5 
6 
7 namespace grail
8 {
9  namespace planning
10  {
14  {
15  friend class DomainTranslator;
16 
17  public:
20  bool TryGetIndexOfObject(const IPlannerObject* object, unsigned int& outIndex) const;
21 
26  template<class ObjectClass>
27  ObjectClass* GetObjectByIndex(unsigned int index) const
28  {
29  auto iter = indexToObjectBinding.find(index);
30  if (iter == indexToObjectBinding.end())
31  {
32  return nullptr;
33  }
34  return static_cast<ObjectClass*>(iter->second);
35  }
36 
37  private:
39  void CreateBinding(const std::vector<IPlannerObject*>& plannerObjects);
40 
41  std::map<const IPlannerObject*, unsigned int> objectToIndexBinding{};
42  std::map<unsigned int, IPlannerObject*> indexToObjectBinding{};
43  };
44  }
45 }
46 #endif //GRAIL_OBJECT_INDEX_BINDING_H
Definition: DomainTranslator.hh:19
The interface to be implemented by classes that should be converted and bound to plan-space WorldObje...
Definition: IPlannerObject.hh:16
Definition: ObjectIndexBinding.hh:14
ObjectClass * GetObjectByIndex(unsigned int index) const
Definition: ObjectIndexBinding.hh:27
bool TryGetIndexOfObject(const IPlannerObject *object, unsigned int &outIndex) const
Definition: ObjectIndexBinding.cpp:12