(C++)  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
GrailDebugger.h
1 #ifndef GRAIL_DEBUGGER_H
2 #define GRAIL_DEBUGGER_H
3 
4 #include "../AIEntity.hh"
5 #include "../AIManager.hh"
6 #include "ITimestampProvider.h"
7 #include "IDebugSnapshotReceiver.h"
8 #include "ISnapshotGenerator.h"
9 #include "GrailStateSnapshotGenerator.h"
10 
11 #include <vector>
12 #include <map>
13 #include <memory>
14 #include <unordered_set>
15 
16 namespace grail
17 {
19  {
20  public:
21  GrailDebugger(const std::shared_ptr<ITimestampProvider>& timestampProvider);
22  ~GrailDebugger() override = default;
23 
29  void AttachToManager(AIManager* manager, bool attachToAllEntities = true);
30 
34  void DetachFromManager(AIManager* manager);
35 
40  void AttachToEntity(AIEntity& entity);
41 
46  void DetachFromEntity(AIEntity& entity);
47 
51  void AddDebugSnapshotReceiver(const AIManager* manager, IDebugSnapshotReceiver* receiver);
52 
56  void RemoveDebugSnapshotReceiver(const AIManager* manager, IDebugSnapshotReceiver* receiver);
57 
61  void Update();
62 
63  // IReasonerChangeObserver interface
64  void OnReasonerSet(AIEntity& entity, Reasoner* newReasoner) override;
65 
66  // IEntityChangeObserver interface
67  void OnEntityAdded(const AIManager& manager, AIEntity& entity) override;
68  void OnEntityRemoved(const AIManager& manager, size_t entityId) override;
69 
70  private:
71  bool AttachToReasoner(AIEntity& entity);
72 
73  std::shared_ptr<ITimestampProvider> timestampProvider = nullptr;
74  std::map<const AIManager*, std::vector<IDebugSnapshotReceiver*>> debugSnapshotReceivers{};
75 
76  std::map<size_t, std::pair<std::unique_ptr<ISnapshotGenerator>, std::unordered_set<const AIManager*>>> reasonerSnapshotGenerators{};
77  std::map<const AIManager*, std::unique_ptr<GrailStateSnapshotGenerator>> grailStateSnapshotGenerators{};
78  };
79 }
80 
81 #endif
The AIEntity class - Defines a basic object which can execute behaviors.
Definition: AIEntity.hh:39
The AIManager class - Manages registered entities and shared blackboards.
Definition: AIManager.hh:35
Definition: GrailDebugger.h:19
void AddDebugSnapshotReceiver(const AIManager *manager, IDebugSnapshotReceiver *receiver)
AddDebugSnapshotReceiver - registers a debug snapshot receiver that can react to newly produced debug...
Definition: GrailDebugger.cpp:96
void DetachFromEntity(AIEntity &entity)
DetachFromEntity - stops the production of debug data for an entity's reasoner.
Definition: GrailDebugger.cpp:85
void AttachToManager(AIManager *manager, bool attachToAllEntities=true)
AttachToManager - attaches the debugger instance to an AIManager.
Definition: GrailDebugger.cpp:11
void RemoveDebugSnapshotReceiver(const AIManager *manager, IDebugSnapshotReceiver *receiver)
AddDebugSnapshotReceiver - removes a debug snapshot receiver.
Definition: GrailDebugger.cpp:117
void AttachToEntity(AIEntity &entity)
AttachToEntity - starts producing debug data for an entity's reasoner.
Definition: GrailDebugger.cpp:77
void DetachFromManager(AIManager *manager)
DetachFromCurrentlyObservedManager - detaches the debugger from the currently selected AI Manager and...
Definition: GrailDebugger.cpp:47
void Update()
Creates debug data for entities and managers that the debugger is attached to, notifies registered sn...
Definition: GrailDebugger.cpp:139
Definition: IDebugSnapshotReceiver.h:7
Definition: AIManager.hh:18
Definition: AIEntity.hh:27
The Reasoner class - Entity's "brain", assigns them behaviors chosen by user-defined algorithms.
Definition: Reasoner.hh:20